Code edit (7 edits merged)
Please save this source code
User prompt
in resetButton.deactivate animate the button out to y=-300 ↪💡 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
do the same for resetbutton.activate ↪💡 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
in menubutton.activate() function animate entrance from y=-300 to y=130 ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (6 edits merged)
Please save this source code
User prompt
for levelText Animate scale to 10 and fade out; did not work, use w & h instead (store inital values before anim) ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
User prompt
when tapping a level in the menu, animate if scale to 10 and fade out (then restore it no inital values) ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
User prompt
use storage plugin to store maxReachedLevelNumber ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
add logs in updateMenuGrid
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'levelText.style.fill = lvlColor;' Line Number: 471
Code edit (5 edits merged)
Please save this source code
User prompt
in updateMenuGrid Fore ach levelText in menuGrid, update the level color depending on puzzleManager.maxReachedLevelNumber
Code edit (3 edits merged)
Please save this source code
User prompt
fix ```levelText.down = function () { log("Tapped level number:", lvl); }; ```to take into account the scope
User prompt
in MenuBoard, add a down event handler on levelText elements and log the tapped level number
Code edit (2 edits merged)
Please save this source code
User prompt
in showWall() animate backgroundWall alpha from 0 to 1
Code edit (5 edits merged)
Please save this source code
User prompt
in cleanMenuState, animate menu exit to the left side
User prompt
in initMenuState, animate menuBoard entrance from the right side
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -385,9 +385,8 @@
var cols = 6;
var cellSize = LK.getAsset('menuCell', {}).width;
// Create grid of menuCell assets
for (var row = 0; row < rows; row++) {
- self.menuGrid[row] = [];
for (var col = 0; col < cols; col++) {
var menuCell = self.attachAsset('menuCell', {
anchorX: 0.5,
anchorY: 0.5,
@@ -395,9 +394,8 @@
y: cellSize / 2 + row * cellSize,
scaleX: col % 2 ? 1 : -1,
scaleY: row % 2 ? 1 : -1
});
- self.menuGrid[row][col] = menuCell;
self.addChild(menuCell);
}
}
// Create grid of menuCell assets
@@ -423,20 +421,41 @@
levelText.alpha = lvl <= puzzleManager.maxReachedLevelNumber ? 1 : 0.6;
levelText.blendMode = 2;
levelText.x = col * cellSize * 1.0 + cellSize / 2 - 90;
levelText.y = row * cellSize * 1.0 + cellSize / 4 + 10;
- if (isDone || isReached) {
- levelText.down = function (level) {
- return function () {
- //{3F.1}
- log("Tapped level number:", level); //{3F.2}
- }; //{3F.3}
- }(lvl); //{3F.4}
- }
+ levelText.down = function (level) {
+ return function () {
+ //{3F.1}
+ log("Tapped level number:", level); //{3F.2}
+ if (level <= puzzleManager.maxReachedLevelNumber) {
+ puzzleManager.selectLevel(level);
+ changeGameState(GAME_STATE.NEW_ROUND);
+ }
+ }; //{3F.3}
+ }(lvl); //{3F.4}
+ self.menuGrid[row][col] = levelText;
self.addChild(levelText);
}
}
}
+ self.updateMenuGrid = function () {
+ // Foreach levelText in menuGrid, update the level color depending on puzzleManager.maxReachedLevelNumber
+ for (var row = 0; row < self.menuGrid.length; row++) {
+ for (var col = 0; col < self.menuGrid[row].length; col++) {
+ var levelText = self.menuGrid[row][col];
+ if (levelText) {
+ var lvl = parseInt(levelText.text);
+ var isDone = lvl < puzzleManager.maxReachedLevelNumber;
+ var isReached = lvl == puzzleManager.maxReachedLevelNumber;
+ var notReached = lvl > puzzleManager.maxReachedLevelNumber;
+ var lvlColor = isDone ? 0x6ad100 : 0xF93827;
+ lvlColor = notReached ? 0x787878 : lvlColor;
+ levelText.style.fill = lvlColor;
+ levelText.alpha = lvl <= puzzleManager.maxReachedLevelNumber ? 1 : 0.6;
+ }
+ }
+ }
+ };
return self;
});
// MenuButton class to represent the menu button
var MenuButton = Container.expand(function () {
@@ -898,8 +917,12 @@
// Core Functions
self.initPuzzle = function () {
self.loadLevel(self.currentLevel);
};
+ self.selectLevel = function (level) {
+ self.currentLevel = level;
+ self.previousLevelNumber = level;
+ };
self.reset = function (noContinue) {
// Remove all existing tiles
self.board.forEach(function (tile) {
// Animate tiles moving randomly out of screen
@@ -1275,8 +1298,11 @@
resetButton.disable();
LK.setTimeout(function () {
self.previousLevelNumber = self.currentLevel;
self.currentLevel++; // Advance to the next level
+ if (self.currentLevel > self.maxReachedLevelNumber) {
+ self.maxReachedLevelNumber = self.currentLevel;
+ }
changeGameState(GAME_STATE.NEW_ROUND); // Change state to newRound
}, 2000);
return true;
}
@@ -1585,9 +1611,8 @@
// Menu State Handlers
function handleMenuStateDown(x, y, obj) {
// Implement logic for handling down event in MENU state
log("Handling down event in MENU state");
- changeGameState(GAME_STATE.NEW_ROUND);
}
function handleMenuStateMove(x, y, obj) {
// Implement logic for handling move event in MENU state
//log("Handling move event in MENU state");
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