Code edit (21 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'anchor')' in or related to this line: 'levelText.anchor.x = 0.5;' Line Number: 125
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -37,10 +37,10 @@
var self = Container.call(this);
self.letter = '';
var blackboardText = new Text2(self.letter, {
size: 120,
- fill: "#ffffff",
- stroke: "#000000",
+ fill: 0xFFFFFF,
+ stroke: 0x000000,
strokeThickness: 10
});
blackboardText.anchor.set(0.5, 0.5);
self.addChild(blackboardText);
@@ -60,9 +60,9 @@
anchorY: 0.5
});
var letterText = new Text2(self.letter, {
size: 150,
- fill: "#000000",
+ fill: 0x000000,
weight: 300
});
letterText.anchor.set(0.5, 0.5);
self.addChild(letterText);
@@ -92,19 +92,22 @@
return self;
});
var LevelText = Container.expand(function () {
var self = Container.call(this);
- var levelTxt = new Text2('Level 1', {
+ self.levelTxt = new Text2('Level 1', {
size: 80,
- fill: "#ffffff",
- stroke: "#000000",
+ fill: 0xDDDDDD,
+ stroke: 0x000000,
strokeThickness: 10,
weight: 800
});
- levelTxt.anchor.x = 0.5;
+ self.levelTxt.anchor.x = 0.5;
//levelTxt.x = 2048 / 2;
//levelTxt.y = 200;
- self.addChild(levelTxt);
+ self.addChild(self.levelTxt);
+ self.updateLabel = function (val) {
+ self.levelTxt.setText('Level ' + val);
+ };
return self;
});
var NextLevelBackground = Container.expand(function () {
var self = Container.call(this);
@@ -145,9 +148,9 @@
anchorY: 0.5
});
var buttonText = new Text2('Submit', {
size: 100,
- fill: "#000000"
+ fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
@@ -244,16 +247,18 @@
}
var streak = 0;
var streakText = new Text2('Streak: 0', {
size: 60,
- fill: "#FFFFED",
- stroke: "#000000",
+ fill: 0xFFFFED,
+ stroke: 0x000000,
strokeThickness: 10,
weight: 800
});
//streakText.anchor.set(-0.5, 0);
-streakText.anchor.set(0, 0);
-LK.gui.topLeft.addChild(streakText);
+//streakText.anchor.set(0, 0);
+streakText.anchor.set(1.1, 0);
+//LK.gui.topLeft.addChild(streakText);
+LK.gui.topRight.addChild(streakText);
//streakText.x += 100;
// Add event listener to streakText
streakText.down = function (x, y, obj) {
showStreakInfoWindow();
@@ -295,10 +300,10 @@
streakText.setText("Streak: " + streak + streakBonus);
}
var scoreTxt = new Text2('Score: 0', {
size: 70,
- fill: "#ADE6D8",
- stroke: "#000000",
+ fill: 0x609e8f,
+ stroke: 0x000000,
strokeThickness: 10,
weight: 800
});
scoreTxt.anchor.set(0.5, 0);
@@ -387,9 +392,9 @@
});
game.addChild(tables);
var levelText = new LevelText();
levelText.x = 2048 / 2;
-levelText.y = 200;
+levelText.y = 250;
game.addChild(levelText);
var teacher = new Teacher();
teacher.x = 2048 / 2 + 380;
teacher.y = 2732 / 2 - 250;
@@ -412,10 +417,10 @@
nextLevelBackground.y = 1500;
game.addChild(nextLevelBackground);
var nextLevelText = new Text2('Level ' + (currentLevel + 1), {
size: 200,
- fill: "#ffffff",
- stroke: "#000000",
+ fill: 0xFFFFFF,
+ stroke: 0x000000,
strokeThickness: 10,
align: 'center',
weight: 800
});
@@ -478,9 +483,10 @@
function advanceToNextLevel() {
if (currentLevel < levels.length - 1) {
currentLevel++;
letters = getLettersForCurrentLevel();
- levelTxt.setText('Level ' + (currentLevel + 1));
+ //levelTxt.levelText.setText('Level ' + (currentLevel + 1));
+ levelText.updateLabel(currentLevel + 1);
clearBlackBoard();
blackboardOffsetY = 0;
resetGameStateForNewLevel();
} else {
@@ -496,10 +502,10 @@
cat.y = 1580;
rabbit.y = 1550;
var congratsText = new Text2('Congratulations!\nYou found all the words!', {
size: 150,
- fill: "#ffffff",
- stroke: "#000000",
+ fill: 0xFFFFFF,
+ stroke: 0x000000,
strokeThickness: 10,
align: 'center',
weight: 800
});
@@ -509,9 +515,10 @@
game.addChild(congratsText);
LK.setTimeout(function () {
congratsText.destroy();
LK.stopMusic();
- LK.showGameOver();
+ //LK.showGameOver();
+ LK.showYouWin();
}, 2000); // Display the message for 3 seconds
}
// Define levels with different sets of letters and acceptable words
var levels3 = [{
@@ -607,10 +614,10 @@
};
function createScoreNotice(x, y, value) {
var label = new Text2('+' + value, {
size: 120,
- fill: "#ADE6D8",
- stroke: "#000000",
+ fill: 0xADE6D8,
+ stroke: 0x000000,
strokeThickness: 10,
weight: 800
});
label.anchor.set(0.5, 0.5);
@@ -679,10 +686,10 @@
streakInfoWindow.addChild(windowBg);
// Create the text for the window
var infoText = new Text2("Your streak increases with each successive correct guess, but is reset to 0 on a wrong guess.\n\nExtend your streak for better score multipliers.", {
size: 60,
- fill: "#ffffff",
- stroke: "#000000",
+ fill: 0xFFFFFF,
+ stroke: 0x000000,
strokeThickness: 10,
align: 'center',
wordWrap: true,
wordWrapWidth: 1500
@@ -693,10 +700,10 @@
streakInfoWindow.addChild(infoText);
// Create the close button
var closeButton = new Text2("Close", {
size: 80,
- fill: "#ff0000",
- stroke: "#000000",
+ fill: 0xFF0000,
+ stroke: 0x000000,
strokeThickness: 10,
align: 'center'
});
closeButton.anchor.set(0.5, 0.5);
A smooth, clean, blank and empty scrabble tile for a game.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A clean, warm and welcoming classroom in a school, facing the blackboard.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A small golden star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.