User prompt
Make text 3x as large and bold
User prompt
Make text 1/3 the size
User prompt
Make text 2/3 the size
User prompt
Like in 2048, only spawn a few tiles when the game starts
User prompt
Add a drag method to game, that detects if we dragged up,down,left or right like 2048
User prompt
Add the logic that allows the game to merge tiles based on finger swipe, like 2048
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'squares[i][j]')' in this line: 'if (squares[i][j]) {' Line Number: 46
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'squares[i][j] = square')' in this line: 'squares[i][j] = square;' Line Number: 38
User prompt
Also add the logic where tiles slide left right up or down when dragging like 2048
User prompt
Use a 2d array to store the tiles
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'squares[i][j] = square')' in this line: 'squares[i][j] = square;' Line Number: 33
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'self.addChild')' in this line: 'self.addChild(gridContainer);' Line Number: 25
Code edit (1 edits merged)
Please save this source code
User prompt
Only spawn tiles on a few squares like 2048
User prompt
Add swipe handler like 2048 that detects if I swipe up, down, left or right
User prompt
add the down and up handlers to stage
User prompt
Add a threshold value to swipe distance, such that swipe is only detected if swipe distance is larger than threshold value
User prompt
Like in 2048, move the tiles up down left or right when I swipe
User prompt
Rather than using squareSize in Tile, parse absolute position values to tile.setPosition
User prompt
in move tile also set absolute tile position
User prompt
Make sure to iterate the array based on swipe direction, in such a fashion that all tiles move fully to the left right up and down like 2048
User prompt
Only allow moveTiles if the target square is not empty
User prompt
Update the tile class to have the squareSize value
User prompt
Only send X and Y into tile setPosition, then in setPosition calculate the actual x and y value
var Tile = Container.expand(function (value) {
var self = Container.call(this);
self.value = value || 2;
var tileGraphics = self.createAsset('tile', 'Tile Graphics', 0, 0);
var tileLabel = new Text2(self.value.toString(), {
size: 300,
fill: '#ffffff',
font: 'bold'
});
tileLabel.anchor.set(0.5, 0.5);
tileLabel.x = tileGraphics.width / 2;
tileLabel.y = tileGraphics.height / 2;
tileGraphics.addChild(tileLabel);
self.setPosition = function (x, y) {
self.x = x;
self.y = y;
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
LK.stageContainer.setBackgroundColor(0xD3D3D3);
var gridContainer = new Container();
gridContainer.x = 44;
gridContainer.y = 200;
self.addChild(gridContainer);
var squares = [];
var gridSize = 4;
var squareSize = 500;
for (var i = 0; i < gridSize; i++) {
for (var j = 0; j < gridSize; j++) {
var square = new Tile();
square.setPosition(i * squareSize, j * squareSize);
squares.push(square);
gridContainer.addChild(square);
}
}
LK.on('tick', function () {});
});