Code edit (16 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: resetButton.hide is not a function' in or related to this line: 'resetButton.hide();' Line Number: 1419
Code edit (1 edits merged)
Please save this source code
Code edit (18 edits merged)
Please save this source code
User prompt
add a new MenuButton class and a menuButton global similar to ResetButon and resetButton
Code edit (1 edits merged)
Please save this source code
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'levelText is not defined' in or related to this line: 'menuCell.addChild(levelText);' Line Number: 398
Code edit (1 edits merged)
Please save this source code
User prompt
add a new class MenuBoard that contains a grid of assets named menuGrid. (use a new asset named menuCell)
Code edit (3 edits merged)
Please save this source code
User prompt
in StartButton fadeOut, apply the same animation as for tile setValue to 0 to each letterGraphics
User prompt
in StartButton, use a container for each letter, add tileGraphics and letterText as children of this container then add the container to self.letterGraphics
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in StartButton, add 5 new texts similars to startText for each letter of the word "START"
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: levelText is not defined' in or related to this line: 'levelText.setText("?");' Line Number: 1149
Code edit (21 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: levelText is not defined' in or related to this line: 'levelText.setText("?");' Line Number: 1145
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (11 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: Error: Invalid color format. Expected 0xRRGGBB format, received: undefined' in or related to this line: 'tween(tileGraphics, {' Line Number: 235
===================================================================
--- original.js
+++ change.js
@@ -376,26 +376,113 @@
self.menuGrid[row] = [];
for (var col = 0; col < cols; col++) {
if (row >= 1 && col < 6) {
var lvl = col + (cols - 1) * (row - 1) + 1;
- lvl = lvl < 10 ? "0" + lvl : lvl;
- var levelText = new Text2(lvl, {
+ var isDone = lvl < puzzleManager.maxReachedLevelNumber;
+ var isReached = lvl == puzzleManager.maxReachedLevelNumber;
+ var notReached = lvl > puzzleManager.maxReachedLevelNumber;
+ var lvlColor = isDone ? 0x6ad100 : 0xF93827;
+ lvlColor = notReached ? 0x787878 : lvlColor;
+ var levelText = new Text2(lvl < 10 ? "0" + lvl : lvl, {
size: 160,
- fill: tileColors[1],
- //0xEAEEE8,
+ fill: lvlColor,
weight: 1000,
dropShadow: true,
dropShadowAngle: Math.PI,
dropShadowDistance: 10
});
- levelText.x = col * cellSize * 1.0 + cellSize / 2 - 80;
- levelText.y = row * cellSize * 1.0;
+ //levelText.anchor.set(0.5, 0.5);
+ 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;
self.addChild(levelText);
}
}
}
return self;
});
+// MenuButton class to represent the menu button
+var MenuButton = Container.expand(function () {
+ var self = Container.call(this);
+ // Asset Attachments
+ var buttonShadow = self.attachAsset('resetButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 10,
+ y: 10,
+ tint: 0x000000,
+ alpha: 0.25
+ });
+ var buttonGraphics = self.attachAsset('resetButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: 0,
+ tint: 0xEAEEE8
+ });
+ self.down = function () {
+ self.disable();
+ tween(self, {
+ rotation: Math.PI * 2 // Rotate 360 degrees
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.rotation = 0; // Restore rotation to 0
+ }
+ });
+ LK.getSound("resetSound").play();
+ // Add functionality for menu button
+ };
+ self.disable = function () {
+ buttonGraphics.alpha = 0.5; // Dim the button to indicate it's disabled
+ self.interactive = false; // Disable interaction
+ tween(self, {
+ scaleX: 0.8,
+ scaleY: 0.8
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ };
+ self.enable = function () {
+ buttonGraphics.alpha = 1.0; // Restore full opacity to indicate it's enabled
+ self.interactive = true; // Enable interaction
+ tween(self, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ };
+ self.activate = function () {
+ self.visible = true;
+ };
+ self.deactivate = function () {
+ self.visible = false;
+ };
+ self.highlight = function () {
+ tween(self, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ }
+ });
+ };
+ return self;
+});
// OperationButton class to represent each operation button
var OperationButton = Container.expand(function (type, index) {
var self = Container.call(this);
// Properties
@@ -797,8 +884,9 @@
self.levelBoardOffsetX = 0; // Initialize levelBoardOffsetX
self.levelBoardOffsetY = 0; // Initialize levelBoardOffsetY
self.currentLevel = debug ? 1 : 1;
self.previousLevelNumber = 1;
+ self.maxReachedLevelNumber = 1;
self.board = [];
self.operations = [];
self.isAnimating = false;
self.selectedOperation = null;
@@ -1475,8 +1563,9 @@
// Menu State Handlers
function handleMenuStateDown(x, y, obj) {
// Implement logic for handling down event in MENU state
log("Handling down event in MENU state");
+ menuBoard.visible = false;
changeGameState(GAME_STATE.NEW_ROUND);
}
function handleMenuStateMove(x, y, obj) {
// Implement logic for handling move event in MENU state
@@ -1784,8 +1873,9 @@
var currentHighlightedTile;
var currentAdjacentTiles = []; // Initialize currentAdjacentTiles as a global variable
var dragNode = null;
var resetButton; // Declare resetButton as a global variable
+var menuButton; // Declare menuButton as a global variable
var tileColors = {
0: 0xEAEEE8,
// White / Gray
1: 0x1E90FF,
@@ -1951,8 +2041,13 @@
// Initialize levelNumberText using LevelNumberText class
levelNumberText = new LevelNumberText(puzzleManager.currentLevel);
backgroundLayer.addChild(levelNumberText);
foregroundLayer.addChild(resetButton);
+ menuButton = new MenuButton();
+ menuButton.x = 150; // Position at top left
+ menuButton.y = 150;
+ menuButton.visible = true; // Make it visible initially
+ foregroundLayer.addChild(menuButton);
menuBoard = new MenuBoard();
middleLayer.addChild(menuBoard);
}
initializeGame();
\ No newline at end of file
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