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
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
in handlePlayingStateDown, if not taping an operation but tapping a tile, play tick sound
===================================================================
--- original.js
+++ change.js
@@ -346,8 +346,32 @@
levelText2.y = centerY + dirY * 2732;
};
return self;
});
+// MenuBoard class to represent a grid of menuCell assets
+var MenuBoard = Container.expand(function () {
+ var self = Container.call(this);
+ self.menuGrid = [];
+ // Define grid dimensions
+ var rows = 5;
+ var cols = 5;
+ 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,
+ x: col * cellSize,
+ y: row * cellSize
+ });
+ self.menuGrid[row][col] = menuCell;
+ self.addChild(menuCell);
+ }
+ }
+ return self;
+});
// OperationButton class to represent each operation button
var OperationButton = Container.expand(function (type, index) {
var self = Container.call(this);
// Properties
@@ -540,9 +564,9 @@
// StartButton class to represent the start button
var StartButton = Container.expand(function () {
var self = Container.call(this);
// Asset Attachments
- var buttonGraphics = self.attachAsset('startButton', {
+ self.buttonGraphics = self.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
@@ -564,8 +588,30 @@
self.letterGraphics = [];
// Individual letter texts for "START"
var letters = ['S', 'T', 'A', 'R', 'T'];
var tileSpacing = 390;
+ var letterPositions = {
+ 0: {
+ 'x': -585,
+ 'y': -300
+ },
+ 1: {
+ 'x': -195,
+ 'y': -300
+ },
+ 2: {
+ 'x': 0,
+ 'y': 0
+ },
+ 3: {
+ 'x': 195,
+ 'y': 300
+ },
+ 4: {
+ 'x': 585,
+ 'y': 300
+ }
+ };
letters.forEach(function (letter, index) {
var letterContainer = new Container();
var tileGraphics = letterContainer.attachAsset('hexTile', {
anchorX: 0.5,
@@ -591,10 +637,11 @@
letterText.visible = true;
letterText.x = 0;
letterContainer.addChild(tileGraphics);
letterContainer.addChild(letterText);
- letterContainer.x = (index - 2) * tileSpacing;
- letterContainer.y = 0;
+ letterContainer.x = letterPositions[index].x; //(index - 2) * tileSpacing;
+ letterContainer.y = letterPositions[index].y;
+ log("letter:", letter, letterContainer.x);
self.letterGraphics.push(letterContainer);
self.addChild(letterContainer);
});
self.fadeOut = function () {
@@ -605,9 +652,20 @@
scaleY: 0,
rotation: Math.PI / 2
}, {
duration: 1000,
- easing: tween.easeOut
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self.buttonGraphics, {
+ alpha: 0
+ }, {
+ duration: 1000,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ }
});
});
};
return self;
@@ -622,8 +680,76 @@
/****
* Game Code
****/
+function _typeof2(o) {
+ "@babel/helpers - typeof";
+ return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
+ return typeof o;
+ } : function (o) {
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
+ }, _typeof2(o);
+}
+function _defineProperty3(e, r, t) {
+ return (r = _toPropertyKey2(r)) in e ? Object.defineProperty(e, r, {
+ value: t,
+ enumerable: !0,
+ configurable: !0,
+ writable: !0
+ }) : e[r] = t, e;
+}
+function _toPropertyKey2(t) {
+ var i = _toPrimitive2(t, "string");
+ return "symbol" == _typeof2(i) ? i : i + "";
+}
+function _toPrimitive2(t, r) {
+ if ("object" != _typeof2(t) || !t) {
+ return t;
+ }
+ var e = t[Symbol.toPrimitive];
+ if (void 0 !== e) {
+ var i = e.call(t, r || "default");
+ if ("object" != _typeof2(i)) {
+ return i;
+ }
+ throw new TypeError("@@toPrimitive must return a primitive value.");
+ }
+ return ("string" === r ? String : Number)(t);
+}
+function _typeof(o) {
+ "@babel/helpers - typeof";
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
+ return typeof o;
+ } : function (o) {
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
+ }, _typeof(o);
+}
+function _defineProperty(e, r, t) {
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
+ value: t,
+ enumerable: !0,
+ configurable: !0,
+ writable: !0
+ }) : e[r] = t, e;
+}
+function _toPropertyKey(t) {
+ var i = _toPrimitive(t, "string");
+ return "symbol" == _typeof(i) ? i : i + "";
+}
+function _toPrimitive(t, r) {
+ if ("object" != _typeof(t) || !t) {
+ return t;
+ }
+ var e = t[Symbol.toPrimitive];
+ if (void 0 !== e) {
+ var i = e.call(t, r || "default");
+ if ("object" != _typeof(i)) {
+ return i;
+ }
+ throw new TypeError("@@toPrimitive must return a primitive value.");
+ }
+ return ("string" === r ? String : Number)(t);
+}
function resetAdjacentTilesScale() {
currentAdjacentTiles.forEach(function (adjTile) {
adjTile.isHighlighted = false;
tween(adjTile, {
@@ -1146,21 +1272,25 @@
/***********************************************************************************************/
function initMenuState() {
// Initialize the game state for MENU
log("Initializing MENU State");
- startButton.visible = true;
if (debug) {
//changeGameState(GAME_STATE.NEW_ROUND);
}
}
+function cleanInitState() {
+ // Clean up the game state for MENU
+ log("Cleaning INIT State");
+ startButton.fadeOut();
+}
function handleMenuLoop() {
// Handle the game loop for MENU state
log("Handling MENU Loop");
}
function cleanMenuState() {
// Clean up the game state for MENU
log("Cleaning MENU State");
- startButton.fadeOut();
+ // Remove menu buttons
}
function initNewRoundState() {
// Initialize the game state for NEW_ROUND
log("Initializing NEW_ROUND State");
@@ -1214,9 +1344,9 @@
log("Changing game state from", currentState, "to", newState);
// Clean up the current state
switch (currentState) {
case GAME_STATE.INIT:
- // Do nothing
+ cleanInitState();
break;
case GAME_STATE.MENU:
cleanMenuState();
break;
@@ -1236,8 +1366,11 @@
currentState = newState;
// Initialize the new state
switch (newState) {
case GAME_STATE.MENU:
+ // Do nothing
+ break;
+ case GAME_STATE.MENU:
initMenuState();
break;
case GAME_STATE.NEW_ROUND:
initNewRoundState();
@@ -1256,8 +1389,11 @@
/****************************************** EVENT HANDLERS *************************************/
/***********************************************************************************************/
game.down = function (x, y, obj) {
switch (currentState) {
+ case GAME_STATE.INIT:
+ handleInitStateDown(x, y, obj);
+ break;
case GAME_STATE.MENU:
handleMenuStateDown(x, y, obj);
break;
case GAME_STATE.PLAYING:
@@ -1271,8 +1407,11 @@
}
};
game.move = function (x, y, obj) {
switch (currentState) {
+ case GAME_STATE.INIT:
+ // Do nothing
+ break;
case GAME_STATE.MENU:
handleMenuStateMove(x, y, obj);
break;
case GAME_STATE.PLAYING:
@@ -1286,8 +1425,11 @@
}
};
game.up = function (x, y, obj) {
switch (currentState) {
+ case GAME_STATE.INIT:
+ // Do nothing
+ break;
case GAME_STATE.MENU:
handleMenuStateUp(x, y, obj);
break;
case GAME_STATE.PLAYING:
@@ -1300,8 +1442,14 @@
log("Unknown state:", currentState);
}
};
// Menu State Handlers
+function handleInitStateDown(x, y, obj) {
+ // Implement logic for handling down event in MENU state
+ log("Handling down event in INIT state");
+ changeGameState(GAME_STATE.MENU);
+}
+// 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);
@@ -1768,10 +1916,10 @@
puzzleManager = new PuzzleManager(game);
startButton = new StartButton();
startButton.x = centerX; // Center horizontally
startButton.y = centerY; // Center vertically
+ startButton.visible = true;
game.addChild(startButton);
- startButton.visible = false;
resetButton = new ResetButton();
resetButton.x = game.width - 150; // Position at top right
resetButton.y = 150;
resetButton.visible = false; // Keep it non-visible initially
@@ -1779,7 +1927,7 @@
levelNumberText = new LevelNumberText(puzzleManager.currentLevel);
backgroundLayer.addChild(levelNumberText);
foregroundLayer.addChild(resetButton);
// Transition to menu state
- changeGameState(GAME_STATE.MENU);
+ //changeGameState(GAME_STATE.INIT);
}
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