Code edit (6 edits merged)
Please save this source code
User prompt
Add a label to Tile showing it's current value
Code edit (1 edits merged)
Please save this source code
User prompt
On the tile font, set maxWidth to 400
User prompt
Make the label bold and the font size 4x as large
User prompt
Add a label to tile showing it's value
User prompt
Use the same tile graphics for all tile values
User prompt
Fix Bug: 'ReferenceError: Can't find variable: Square' in this line: 'var square = new Square();' Line Number: 26
User prompt
Update the Square class to a Tile class that's appropriate for the game 2048
User prompt
Set container x to 44 and y to 200
User prompt
Don’t use grid start x and y anywhere in the code
User prompt
Remove grid start x and y
User prompt
Set background to light grey
User prompt
Set container x to 44
User prompt
Create a container for the grid in the games class
User prompt
Set square anchor to 0.0
Initial prompt
Grid game
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: 100, fill: '#ffffff' }); tileLabel.anchor.set(0.5, 0.5); tileLabel.x = tileGraphics.width / 2; tileLabel.y = tileGraphics.height / 2; self.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 () {}); });
===================================================================
--- original.js
+++ change.js
@@ -1,8 +1,16 @@
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: 100,
+ fill: '#ffffff'
+ });
+ tileLabel.anchor.set(0.5, 0.5);
+ tileLabel.x = tileGraphics.width / 2;
+ tileLabel.y = tileGraphics.height / 2;
+ self.addChild(tileLabel);
self.setPosition = function (x, y) {
self.x = x;
self.y = y;
};