Code edit (3 edits merged)
Please save this source code
User prompt
add a new global showHintsInterval; then use it to delay gameHints.showHint1(); call by 1 sec
Code edit (21 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: isEnabled is not defined' in or related to this line: 'if (isEnabled) {' Line Number: 985
Code edit (5 edits merged)
Please save this source code
User prompt
in handlePlayingStateUp, find a way to exit the `puzzleManager.board.forEach` loop when operation is applied to a tile because `return`doesn't seem to work
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of null (reading 'type')' in or related to this line: 'var newValue = Math.max(0, currentTile.value + parseInt(operation.type));' Line Number: 1541
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2170 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2170 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2170 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2170 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2173 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2173 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2174 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2174 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (15 edits merged)
Please save this source code
Code edit (25 edits merged)
Please save this source code
Code edit (25 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -144,8 +144,10 @@
var self = Container.call(this);
self.x = centerX;
self.y = centerY;
self.visible = false;
+ self.hasShowHint = 0;
+ self.visible = false;
// Attach hintPopup asset
self.popup = self.attachAsset('hintPopup', {
anchorX: 0.5,
anchorY: 0.5,
@@ -168,48 +170,71 @@
});
self.hintText.x = self.popup.x - 350;
self.hintText.y = self.popup.y - 45;
self.addChild(self.hintText);
+ self.showHint = function () {
+ if (self.hasShowHint == 0) {
+ // Show hint 1
+ self.showHint1();
+ return;
+ }
+ if (self.hasShowHint == 1) {
+ // Show hint 1
+ self.showHint2();
+ return;
+ }
+ self.visible = false;
+ log("All hints shown");
+ };
self.showHint1 = function () {
- hasShowHint = true;
self.visible = true;
self.alpha = 0;
self.hintText.setText("Drag this operation");
- self.x = centerX;
+ self.chevron.x = -530;
+ self.chevron.y = 0;
+ self.chevron.rotation = Math.PI * 0.5, self.x = centerX;
self.y = 2300;
tween(self, {
alpha: 1
}, {
duration: 500,
- easing: tween.easeIn
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ self.hasShowHint = 1;
+ }
});
};
self.showHint2 = function () {
- self.alpha = 0;
+ //self.alpha = 0;
self.hintText.setText(" Drop it on a tile");
self.chevron.rotation = 0;
self.chevron.x = 0;
self.chevron.y = 250;
self.x = centerX;
- self.y = 600;
+ self.y = self.y == 2300 ? 2300 : -500;
tween(self, {
- alpha: 1
+ y: 600
}, {
duration: 500,
- easing: tween.easeIn
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ self.hasShowHint = 2;
+ }
});
};
self.hideHint = function () {
+ self.alpha = 1;
tween(self, {
- alpha: 1
+ alpha: 0
}, {
duration: 500,
easing: tween.easeIn,
- onFinish: function onFinish() {
- self.visible = false;
- }
+ onFinish: function onFinish() {}
});
};
+ self.removeHint = function () {
+ self.visible = false;
+ };
return self;
});
/***********************************************************************************************/
/******************************************* ASSETS CLASSES ************************************/
@@ -505,8 +530,9 @@
levelText.baseX = levelText.x;
levelText.baseY = levelText.y;
levelText.down = function (levelText, level) {
return function () {
+ levelText.interactive = false;
log("levelText currentState:", currentState, " isMenuReady=", isMenuReady); //{3F.2}
if (!isMenuReady) {
log("Menu not ready.", level); //{3F.2}
return;
@@ -571,8 +597,9 @@
// levelText.setStyle({
// fill: lvlColor
// });
levelText.tint = lvlColor;
+ levelText.interactive = true;
levelText.alpha = lvl <= puzzleManager.maxReachedLevelNumber ? 1 : 0.6;
log("Level alpha set to:", levelText.alpha); // Log the alpha value being set
}
}
@@ -701,8 +728,9 @@
tint: 0x787878,
blendMode: 1
});
self.down = function () {
+ self.interactive = false;
puzzleManager.reset(true);
LK.getSound("resetSound").play();
resetButton.deactivate();
menuBoard.updateMenuGrid();
@@ -735,8 +763,9 @@
self.activate = function () {
if (self.visible) {
return;
}
+ self.interactive = true;
self.visible = true;
self.y = -300;
tween(self, {
y: 130
@@ -892,8 +921,9 @@
LK.getSound("resetSound").play();
puzzleManager.reset(); // Reset the level puzzle
};
self.disable = function () {
+ log("Reset button disable...");
buttonGraphics.alpha = 0.5; // Dim the button to indicate it's disabled
self.interactive = false; // Disable interaction
tween(self, {
scaleX: 0.8,
@@ -903,8 +933,9 @@
easing: tween.easeOut
});
};
self.enable = function () {
+ log("Reset button enable...");
buttonGraphics.alpha = 1.0; // Restore full opacity to indicate it's enabled
self.interactive = true; // Enable interaction
tween(self, {
scaleX: 1.0,
@@ -914,8 +945,9 @@
easing: tween.easeOut
});
};
self.activate = function () {
+ log("Reset button activate...");
self.visible = true;
self.y = -300;
tween(self, {
y: 130
@@ -924,14 +956,16 @@
easing: tween.easeOut
});
};
self.deactivate = function () {
+ log("Reset button deactivate...");
tween(self, {
y: -300
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
+ log("Reset button deactivate : hiding");
self.visible = false;
}
});
};
@@ -1171,8 +1205,9 @@
self.currentLevel = level;
self.previousLevelNumber = level;
};
self.reset = function (noContinue) {
+ gameHints.removeHint();
// Remove all existing tiles
self.board.forEach(function (tile) {
// Animate tiles moving randomly out of screen
tween(tile, {
@@ -1547,8 +1582,9 @@
resetButton.disable();
LK.setTimeout(function () {
self.previousLevelNumber = self.currentLevel;
self.currentLevel++; // Advance to the next level
+ gameHints.removeHint();
if (self.currentLevel > self.maxReachedLevelNumber) {
self.maxReachedLevelNumber = self.currentLevel; //{b6.1}
storage.maxReachedLevelNumber = self.maxReachedLevelNumber; // Store in storage
} //{b6.2}
@@ -1676,20 +1712,8 @@
var delayAnim = startButton.visible ? 800 : 0;
LK.setTimeout(function () {
menuBoard.animateEntrance();
}, delayAnim);
- //isMenuReady = true;
- /*
- tween(menuBoard, {
- x: 0
- }, {
- duration: 1000,
- easing: tween.easeOut,
- onFinish: function onFinish() {
- isMenuReady = true;
- }
- });
- */
menuButton.deactivate();
}
function handleMenuLoop() {
// Handle the game loop for MENU state
@@ -1702,20 +1726,8 @@
menuBoard.animateExit(function () {
menuBoard.visible = false;
backgroundImage.hideWall();
});
- // Animate menuBoard exit to the left side
- /*tween(menuBoard, {
- x: -2048
- }, {
- duration: 1000,
- easing: tween.easeIn,
- onFinish: function onFinish() {
- menuBoard.visible = false;
- backgroundImage.hideWall();
- }
- });
- */
}
function initNewRoundState() {
// Initialize the game state for NEW_ROUND
log("Initializing NEW_ROUND State");
@@ -1739,24 +1751,30 @@
}
function initPlayingState() {
// Initialize the game state for PLAYING
log("Initializing PLAYING State");
- menuButton.activate();
resetButton.disable();
resetButton.activate(); // Make resetButton visible in PLAYING state
- if (!hasShowHint && puzzleManager.currentLevel == 1) {
+ if (puzzleManager.currentLevel == 1) {
showHintsInterval = LK.setTimeout(function () {
gameHints.showHint1();
- }, 1000);
+ }, 2000);
}
+ LK.setTimeout(function () {
+ menuButton.activate();
+ }, 3000);
}
function handlePlayingLoop() {
// Handle the game loop for PLAYING state
log("Handling PLAYING Loop");
}
function cleanPlayingState() {
// Clean up the game state for PLAYING
log("Cleaning PLAYING State");
+ if (showHintsInterval) {
+ LK.clearTimeout(showHintsInterval);
+ }
+ menuButton.deactivate();
resetButton.deactivate();
}
function initScoreState() {
// Initialize the game state for SCORE
@@ -1909,8 +1927,14 @@
duration: 500,
easing: tween.easeOut
});
LK.getSound('operationSelect').play();
+ if (puzzleManager.currentLevel == 1 && gameHints.hasShowHint == 1) {
+ LK.clearTimeout(showHintsInterval);
+ showHintsInterval = LK.setTimeout(function () {
+ gameHints.showHint2();
+ }, 800);
+ }
return;
}
});
if (!dragNode) {
@@ -2086,8 +2110,12 @@
dragNode.destroy();
}
}
});
+ if (puzzleManager.currentLevel == 1 && gameHints.hasShowHint == 2) {
+ LK.clearInterval(showHintsInterval);
+ gameHints.removeHint();
+ }
} else {
log("Operation button is NOT above tile at position:", tile.x, tile.y); // Log when operation button is not above a tile
}
});
tick
Sound effect
tileEntrance
Sound effect
tileRemove
Sound effect
operationSelect
Sound effect
operationCancel
Sound effect
tileChangeValue
Sound effect
resetSound
Sound effect
levelFailed
Sound effect
menuLevelSelect
Sound effect
menuCellEnter
Sound effect
applause
Sound effect
bgMusic
Music
tada
Sound effect