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
Code edit (20 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: tile is not defined' in or related to this line: 'tween(tile, {' Line Number: 945
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -352,10 +352,11 @@
self.type = type;
self.index = index;
self.isSelected = false;
self.rotation = 0;
- self.baseX = 0; // Initialize baseX to store initial x position
- self.baseY = 0; // Initialize baseY to store initial y position
+ self.baseX = 0;
+ self.baseY = 0;
+ self.baseR = 0;
self.visible = false;
self.interactive = true;
self.alpha = 1;
var buttonSize = LK.getAsset('operationButton', {}).width;
@@ -399,13 +400,15 @@
self.valueText.x = buttonGraphics.x;
self.valueText.y = buttonGraphics.y;
self.valueText = self.addChild(self.valueText);
// Functions
- self.setBasePosition = function (x, y) {
+ self.setBasePosition = function (x, y, r) {
self.x = x;
self.y = y;
+ self.rotation = r;
self.baseX = x;
self.baseY = y;
+ self.baseR = r;
};
self.preselect = function () {
log("operation preselect...");
var scaleRatio = 2; //{2S.1}
@@ -624,9 +627,10 @@
self.createBoard();
self.fillTilesNeighbors();
self.createOperations();
LK.setTimeout(self.animateTilesEntrance, levelNumber == 1 ? 0 : 800);
- LK.setTimeout(self.updateOperations, 900);
+ LK.setTimeout(self.animateOperationsEntrance, 900);
+ //LK.setTimeout(self.updateOperations, 900);
};
self.createBoard = function () {
self.board = [];
// Max grid for 200px tiles = 11x7
@@ -778,67 +782,42 @@
});
self.operations = [];
var baseX = 100;
var baseY = 2600;
- for (var i = self.levelData.operations.length - 1; i >= 0; i--) {
+ for (var i = 0; i < self.levelData.operations.length; i++) {
var opType = self.levelData.operations[i];
var operation = new OperationButton(opType, i);
self.operations.push(operation);
- var operationX = i == 0 ? baseX : baseX + (i - 1) * 75;
- log("createOperations:", i, operationX);
- var operationY = baseY;
- operation.setBasePosition(operationX, operationY); // Space buttons evenly and position near the bottom
+ var operationX = operationsSlots[i].x;
+ var operationY = operationsSlots[i].y;
+ var operationR = operationsSlots[i].r;
+ operation.setBasePosition(operationX, operationY, operationR); // Space buttons evenly and position near the bottom
self.game.addChild(operation);
}
};
self.updateOperations = function () {
log("updateOperations:", self.operations);
- if (self.operations && self.operations.length > 0) {
- var operationsSlots = {
- 0: {
- x: 200,
- y: 2300
- },
- 1: {
- x: 400,
- y: 2450
- },
- 2: {
- x: 600,
- y: 2600
- },
- 3: {
- x: 900,
- y: 2600
- },
- 4: {
- x: 1100,
- y: 2450
- },
- 5: {
- x: 1300,
- y: 2300
- }
- };
- var baseX = operationsSlots[0].x;
- var baseY = operationsSlots[0].y;
- for (var i = self.levelData.operations.length - 1; i >= 0; i--) {
- if (self.operations[i]) {
- var op = self.operations[i];
- op.show();
- var operationX = operationsSlots[i].x;
- var operationY = operationsSlots[i].y;
- log("Updating :", i, " old x=", op.x, " => operationX:", operationX);
- tween(op, {
- x: operationX,
- y: operationY
- }, {
- //{4S.2}
- duration: 500,
- // Duration of the animation in milliseconds //{4S.3}
- easing: tween.easeOut // Easing function for smooth transition //{4S.4}
- }); //{4S.5}
- }
+ if (!self.operations || !self.operations.length) {
+ return;
+ }
+ for (var i = 0; i < self.levelData.operations.length; i++) {
+ if (self.operations[i]) {
+ var op = self.operations[i];
+ op.show();
+ var operationX = op.baseX; // operationsSlots[i].x;
+ var operationY = op.baseY; // operationsSlots[i].y;
+ var operationR = op.baseR; // operationsSlots[i].r;
+ log("Updating :", i, " old x=", op.x, " => operationX:", operationX);
+ tween(op, {
+ x: operationX,
+ y: operationY,
+ rotation: operationR
+ }, {
+ //{4S.2}
+ duration: 500,
+ // Duration of the animation in milliseconds //{4S.3}
+ easing: tween.easeOut // Easing function for smooth transition //{4S.4}
+ }); //{4S.5}
}
}
};
self.applyOperation = function (operation, tile) {
@@ -919,9 +898,8 @@
self.board.forEach(function (tile, index) {
// Place tiles randomly out of the screen
tile.x = Math.random() > 0.5 ? -200 - Math.random() * 1000 : 2248 + Math.random() * 1000;
tile.y = Math.random() > 0.5 ? -200 - Math.random() * 1000 : 2732 + Math.random() * 1000;
- ;
//log("animateTilesEntrance #" + index, tile.x, tile.y);
tile.visible = true;
if (index < 6) {
LK.setTimeout(function () {
@@ -937,8 +915,27 @@
easing: tween.bounceOut
});
});
};
+ self.animateOperationsEntrance = function () {
+ self.operations.forEach(function (op, index) {
+ // Place tiles randomly out of the screen
+ op.x = Math.random() > 0.5 ? -200 - Math.random() * 1000 : 2248 + Math.random() * 1000;
+ op.x = Math.random() > 0.5 ? -200 - Math.random() * 1000 : 2248 + Math.random() * 1000;
+ op.rotation = Math.random() * Math.PI * 2;
+ //log("animateOperationsEntrance #" + index, op.x, op.y);
+ op.visible = true;
+ // Animate tiles to their base positions
+ tween(op, {
+ x: op.baseX,
+ y: op.baseY,
+ rotation: op.baseR
+ }, {
+ duration: 800,
+ easing: tween.bounceOut
+ });
+ });
+ };
self.checkWinCondition = function () {
log("checkWinCondition... Active tiles:", self.activeTileCount);
if (self.activeTileCount <= 0) {
self.playVictoryAnimation();
@@ -1224,9 +1221,10 @@
function handlePlayingStateDown(x, y, obj) {
// Implement logic for handling down event in PLAYING state
log("Handling down event in PLAYING state", obj);
puzzleManager.operations.forEach(function (operation) {
- if (operation.isSelected && x >= operation.x - operation.width / 2 && x <= operation.x + operation.width / 2 && y >= operation.y - operation.height / 2 && y <= operation.y + operation.height / 2) {
+ //operation.isSelected &&
+ if (x >= operation.x - operation.width / 2 && x <= operation.x + operation.width / 2 && y >= operation.y - operation.height / 2 && y <= operation.y + operation.height / 2) {
dragNode = operation;
tween(operation, {
rotation: 0,
scaleX: 0.6,
@@ -1375,11 +1373,14 @@
if (!tileFound) {
log("Operation button not above any tile");
LK.getSound('operationCancel').play();
tween(dragNode, {
- x: rightOperationPreselectX,
- y: rightOperationPreselectY,
- rotation: rightOperationPreselectR,
+ x: dragNode.baseX,
+ //rightOperationPreselectX,
+ y: dragNode.baseY,
+ //rightOperationPreselectY,
+ rotation: dragNode.baseR || 0,
+ //rightOperationPreselectR,
scaleX: 1,
scaleY: 1
}, {
duration: 500,
@@ -1470,12 +1471,44 @@
8: 0xFFFF00,
// Yellow
9: 0xFF0000 // Red
};
+var operationsSlots = {
+ 0: {
+ x: 180,
+ y: 2280,
+ r: 0.15
+ },
+ 1: {
+ x: 430,
+ y: 2450,
+ r: 0.15
+ },
+ 2: {
+ x: 680,
+ y: 2600,
+ r: 0.15
+ },
+ 3: {
+ x: 1380,
+ y: 2600,
+ r: -0.15
+ },
+ 4: {
+ x: 1630,
+ y: 2450,
+ r: -0.15
+ },
+ 5: {
+ x: 1880,
+ y: 2280,
+ r: -0.15
+ }
+};
var levelConfigs = {
1: {
"tiles": [["", 1, ""], ["", 1, 1], [1, 1, 1], ["", 1, 1], ["", 1, ""]],
- "operations": ['-1', '-1', '-1', '-1', '-1', '-1']
+ "operations": ['-1', '-1', '-1', '+1', '+1', '+1']
},
2: {
"tiles": [["", 1, ""], ["", 1, 1], [2, 2, 2], ["", 1, 1], ["", 1, ""]],
"operations": ['-1', '-1']
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