Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'width')' in or related to this line: 'self.boxGraphics.width = boardSize;' Line Number: 34
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'spaceingRatio is not defined' in or related to this line: 'var tileSize = boardSize / ((gridSize + 1) * spaceingRatio) + gridSize;' Line Number: 59
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: 'boad is not defined' in or related to this line: 'boad.y = 2732 / 2;' Line Number: 59
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'width')' in or related to this line: 'var startX = background.width / 2;' Line Number: 21
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'alpha')' in or related to this line: 'box.boxGraphics.alpha = 0.2;' Line Number: 49
Code edit (1 edits merged)
Please save this source code
User prompt
place 5 x 5 boxes evenly spaced inside background object, with 50 pixels between them and edges
Code edit (2 edits merged)
Please save this source code
User prompt
make a background graphic
Code edit (1 edits merged)
Please save this source code
Initial prompt
Puzzle 2
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> var Board = Container.expand(function () { var self = Container.call(this); var boxGraphics = self.attachAsset('board', { anchorX: 0.5, anchorY: 0.5 }); self.setup = function () { var boxSize = 100; var boxSpacing = 20; var startX = -self.width / 2; var startY = -self.height / 2; //0; //background.y - background.height / 2 + boxSpacing; for (var i = 0; i < 10; i++) { for (var j = 0; j < 10; j++) { var box = self.addChild(new Box()); box.x = 70 + startX + i * (boxSize + boxSpacing); box.y = 70 + startY + j * (boxSize + boxSpacing); box.setAlpha(0.2); } } }; //self.setup(); self.paint = function () { if (self.boxGraphics) { self.boxGraphics.width = boardSize; self.boxGraphics.height = boardSize; } var startX = -self.width / 2; var startY = -self.height / 2; var boxSize = calculateTileSize(); var boxSpacing = boxSize * spacingRatio; var offset = boxSize / 2 + boxSpacing; for (var i = 0; i < gridSize; i++) { for (var j = 0; j < gridSize; j++) { var box = self.addChild(new Box()); box.x = offset + startX + i * (boxSize + boxSpacing); box.y = offset + startY + j * (boxSize + boxSpacing); box.setAlpha(0.2); } } }; self.paint(); }); var Box = Container.expand(function () { var self = Container.call(this); var boxGraphics = self.attachAsset('box', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.setAlpha = function (i) { self.alpha = i; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var gridSize = 6; var spacingRatio = 0.2; var boardSize = 1600; function calculateTileSize() { // Example of getting desired tileSize depending on gridSize (for different size grids) // maintaining 1600px board size and 0.2 gutter between tiles. var tileSize = boardSize / ((gridSize + 1) * spacingRatio + gridSize); return tileSize; console.log(tileSize); } var tileSize = calculateTileSize(); var board = new Board(); board.x = 1024; board.y = 2732 / 2; game.addChild(board); // Click handler game.down = function (x, y, obj) { //board.scale.x *= 1.2; //board.scale.y *= 1.2; };
===================================================================
--- original.js
+++ change.js
@@ -22,9 +22,29 @@
box.setAlpha(0.2);
}
}
};
- self.setup();
+ //self.setup();
+ self.paint = function () {
+ if (self.boxGraphics) {
+ self.boxGraphics.width = boardSize;
+ self.boxGraphics.height = boardSize;
+ }
+ var startX = -self.width / 2;
+ var startY = -self.height / 2;
+ var boxSize = calculateTileSize();
+ var boxSpacing = boxSize * spacingRatio;
+ var offset = boxSize / 2 + boxSpacing;
+ for (var i = 0; i < gridSize; i++) {
+ for (var j = 0; j < gridSize; j++) {
+ var box = self.addChild(new Box());
+ box.x = offset + startX + i * (boxSize + boxSpacing);
+ box.y = offset + startY + j * (boxSize + boxSpacing);
+ box.setAlpha(0.2);
+ }
+ }
+ };
+ self.paint();
});
var Box = Container.expand(function () {
var self = Container.call(this);
var boxGraphics = self.attachAsset('box', {
@@ -46,13 +66,19 @@
/****
* Game Code
****/
-var gridSize = 10;
+var gridSize = 6;
var spacingRatio = 0.2;
var boardSize = 1600;
-var tileSize = boardSize / ((gridSize + 1) * spacingRatio) + gridSize;
-console.log(tileSize);
+function calculateTileSize() {
+ // Example of getting desired tileSize depending on gridSize (for different size grids)
+ // maintaining 1600px board size and 0.2 gutter between tiles.
+ var tileSize = boardSize / ((gridSize + 1) * spacingRatio + gridSize);
+ return tileSize;
+ console.log(tileSize);
+}
+var tileSize = calculateTileSize();
var board = new Board();
board.x = 1024;
board.y = 2732 / 2;
game.addChild(board);
A large calm background drawing for a puzzle game, in dark calm blueish colors and non-confusing content. High definition. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A quadratic polished dark blue marble slate. Front perspective with right angles. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A white question mark in a circle, like for a help button in a game.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A white X in a circle, like for a close window button in a game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A white questionmark on a black background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A green check mark on a dark background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.