/**** * Classes ****/ var Dice = Container.expand(function () { var self = Container.call(this); var diceGraphics = self.attachAsset('Dice', { anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ // Create array to hold all dice var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Create array to hold all dice var diceArray = []; // Calculate center positions for two columns var centerX = 2048 / 2; var centerY = 2732 / 2; var columnSpacing = 250; // Space between columns var rowSpacing = 220; // Space between rows // Create 8 dice in two columns (4 rows each) for (var col = 0; col < 2; col++) { for (var row = 0; row < 4; row++) { var dice = new Dice(); // Position dice in grid dice.x = centerX + (col - 0.5) * columnSpacing; dice.y = centerY + (row - 1.5) * rowSpacing; // Add to game and array game.addChild(dice); diceArray.push(dice); } }
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,42 @@
-/****
+/****
+* Classes
+****/
+var Dice = Container.expand(function () {
+ var self = Container.call(this);
+ var diceGraphics = self.attachAsset('Dice', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
+// Create array to hold all dice
var game = new LK.Game({
backgroundColor: 0x000000
-});
\ No newline at end of file
+});
+
+/****
+* Game Code
+****/
+// Create array to hold all dice
+var diceArray = [];
+// Calculate center positions for two columns
+var centerX = 2048 / 2;
+var centerY = 2732 / 2;
+var columnSpacing = 250; // Space between columns
+var rowSpacing = 220; // Space between rows
+// Create 8 dice in two columns (4 rows each)
+for (var col = 0; col < 2; col++) {
+ for (var row = 0; row < 4; row++) {
+ var dice = new Dice();
+ // Position dice in grid
+ dice.x = centerX + (col - 0.5) * columnSpacing;
+ dice.y = centerY + (row - 1.5) * rowSpacing;
+ // Add to game and array
+ game.addChild(dice);
+ diceArray.push(dice);
+ }
+}
\ No newline at end of file