User prompt
Reorder timertext for all trees 1-16 to be before background2 image and in front of grids on the screen.
User prompt
Reposition timer text for all trees to be behind background2 and in front of grids
User prompt
Reposition timer text for all trees to be behind background2 when it's visible and in front of grids
User prompt
Hide the text behind the background2 don't show it when its open
User prompt
Hide the text behind the background2 don't show it when its open
User prompt
let the time text of all trees to be behind the background2 & 3 and front of grids on the screen.
User prompt
fix tree16 timetext
Code edit (1 edits merged)
Please save this source code
User prompt
remove timer from top of background1
User prompt
the time you add it on the top of background1 is for tree15 so reposition it again with tree15!
User prompt
Now fix tree15
Code edit (1 edits merged)
Please save this source code
User prompt
Move the tree16 to slot16 in the fourth line of slots at the 4th one
User prompt
set the tree16 position in the slot16 its with tree15 in slot15!
User prompt
Now for tree 15 & 16
Code edit (1 edits merged)
Please save this source code
User prompt
Now for tree 13 & 14
User prompt
now for tree12
User prompt
now for tree11
User prompt
Ensure only one timer text appears for tree10 and reset it when moved.
User prompt
I want to remove it from background1 but let it for the trees.
User prompt
Add timetext for tree8 there is no timer for it showing on the screen like other trees!
User prompt
Now for tree 7 & 8
User prompt
Now for tree 5 & 6
User prompt
Do the same for tree 3 & 4
/**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var background1 = LK.getAsset('background1', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, // Center horizontally y: 2732 / 2, // Center vertically speed: 5 // Add speed property for background1 }); background1.dragOffset = { x: 0, y: 0 }; // Initialize dragOffset // Add drag functionality to background1 background1.down = function (x, y, obj) { this.dragging = true; this.data = obj; var newPosition = this.parent.toLocal(obj.global); this.dragOffset.x = this.x - newPosition.x; // Calculate offset this.dragOffset.y = this.y - newPosition.y; // Calculate offset }; background1.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); var deltaX = newPosition.x + this.dragOffset.x - this.x; // Calculate deltaX var deltaY = newPosition.y + this.dragOffset.y - this.y; // Calculate deltaY this.x += deltaX; // Update position this.y += deltaY; // Update position button2Text.x -= deltaX; // Prevent button2Text from moving button2Text.y -= deltaY; // Prevent button2Text from moving button1Text.x -= deltaX; // Prevent button1Text from moving button1Text.y -= deltaY; // Prevent button1Text from moving // Sync grid movement directly with background1 game.children.forEach(function (child) { if (child !== background1 && child !== buildAsset && child !== button1Asset && child !== button2Asset && child !== background2 && child !== background3 && child !== scrollbar && child !== scrollbutton && child !== scrollbutton3 && child !== scrollbar3) { child.x += deltaX; // Move grid with the same delta as background1 child.y += deltaY; // Move grid with the same delta as background1 } }); } }; background1.up = function () { this.dragging = false; this.data = null; // Removed timer text addition and positioning from background1 }; var gridSize = 200; var gridSpacing = 0.5; var gridCount = 10; var totalGrids = 100; var startX = 2048 / 2 - (gridSize + gridSpacing) * (gridCount - 1) / 2; var startY = 2732 / 2 - (gridSize + gridSpacing) * (gridCount - 1) / 2; for (var j = 0; j < totalGrids / gridCount; j++) { for (var i = 0; i < gridCount; i++) { var grid = LK.getAsset('Grid', { anchorX: 0.5, anchorY: 0.5, x: startX + i * (gridSize + gridSpacing), y: startY + j * (gridSize + gridSpacing), speed: 5 }); game.addChild(grid); } } game.addChildAt(background1, 0); game.children.forEach(function (child) { if (child.assetId === 'Grid') { game.setChildIndex(child, game.children.length - 1); } }); var scrollbar = LK.getAsset('scrollbar', { anchorX: 1.0, anchorY: 0.0, x: 2048, y: 0, visible: false // Initially hidden }); var scrollbutton = LK.getAsset('scrollbutton', { anchorX: 1.0, anchorY: 0.5, x: 2048, y: 0, visible: false // Initially hidden }); game.addChildAt(background1, 0); var background2 = LK.getAsset('background2', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0, speed: 10, // Speed property for background2 visible: false // Initially hidden }); game.addChildAt(background2, game.children.length); game.addChild(scrollbar); game.addChild(scrollbutton); background2.children.forEach(function (child) { return child.visible = false; }); var background3 = LK.getAsset('background3', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0, speed: 10, // Speed property for background3 visible: false // Initially hidden }); game.children.forEach(function (child) { if (child.assetId === 'Grid') { game.setChildIndex(child, game.children.length - 1); } }); game.addChildAt(background3, game.children.length); background3.children.forEach(function (child) { return child.visible = false; }); var scrollbar3 = LK.getAsset('scrollbar', { anchorX: 1.0, anchorY: 0.0, x: 2048, y: 0, visible: false // Initially hidden }); game.addChild(scrollbar3); var scrollbutton3 = LK.getAsset('scrollbutton', { anchorX: 1.0, anchorY: 0.5, x: 2048, y: 0, visible: false // Initially hidden }); game.addChild(scrollbutton3); var slotSpacing3 = 50; // Define the space between slots for background3 for (var i = 0; i < 4; i++) { var slot3 = LK.getAsset('Slot', { anchorX: 0.5, anchorY: 0.5, x: i * (slotSpacing3 + 450) + slotSpacing3 + 200, y: 300 // Arbitrary y position }); background3.addChildAt(slot3, background3.children.length); // Add trees to the slots of background3 if (i === 0) { var tree1 = LK.getAsset('tree1', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree1); tree1.down = function (x, y, obj) { var duplicate = LK.getAsset('tree1', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); game.children.forEach(function (child) { if (child.assetId === 'Grid') { child.visible = true; } }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 1) { var tree2 = LK.getAsset('tree2', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree2); tree2.down = function (x, y, obj) { var duplicate = LK.getAsset('tree2', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 2) { var tree3 = LK.getAsset('tree3', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree3); tree3.down = function (x, y, obj) { var duplicate = LK.getAsset('tree3', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 3) { var tree4 = LK.getAsset('tree4', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree4); tree4.down = function (x, y, obj) { var duplicate = LK.getAsset('tree4', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } } // Add 4 slots below the first slots that are synced in background3 for (var i = 0; i < 4; i++) { var slot3 = LK.getAsset('Slot', { anchorX: 0.5, anchorY: 0.5, x: i * (slotSpacing3 + 450) + slotSpacing3 + 200, y: 900 // Increase y position to add more space }); background3.addChildAt(slot3, background3.children.length); // Add trees to the slots of background3 if (i === 0) { var tree5 = LK.getAsset('tree5', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree5); tree5.down = function (x, y, obj) { var duplicate = LK.getAsset('tree5', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 1) { var tree6 = LK.getAsset('tree6', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree6); tree6.down = function (x, y, obj) { var duplicate = LK.getAsset('tree6', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 2) { var tree7 = LK.getAsset('tree7', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree7); tree7.down = function (x, y, obj) { var duplicate = LK.getAsset('tree7', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 3) { var tree8 = LK.getAsset('tree8', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree8); tree8.down = function (x, y, obj) { var duplicate = LK.getAsset('tree8', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } } // Add another 4 slots below the second 4 slots for (var i = 0; i < 4; i++) { var slot3 = LK.getAsset('Slot', { anchorX: 0.5, anchorY: 0.5, x: i * (slotSpacing3 + 450) + slotSpacing3 + 200, y: 1500 // Increase y position to add more space }); background3.addChildAt(slot3, background3.children.length); // Add trees to the slots of background3 if (i === 0) { var tree9 = LK.getAsset('tree9', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree9); tree9.down = function (x, y, obj) { var duplicate = LK.getAsset('tree9', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 1) { var tree10 = LK.getAsset('tree10', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree10); tree10.down = function (x, y, obj) { var duplicate = LK.getAsset('tree10', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 2) { var tree11 = LK.getAsset('tree11', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree11); tree11.down = function (x, y, obj) { var duplicate = LK.getAsset('tree11', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 3) { var tree12 = LK.getAsset('tree12', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree12); tree12.down = function (x, y, obj) { var duplicate = LK.getAsset('tree12', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } } // Add another 4 slots below the third 4 slots for (var i = 0; i < 4; i++) { var slot3 = LK.getAsset('Slot', { anchorX: 0.5, anchorY: 0.5, x: i * (slotSpacing3 + 450) + slotSpacing3 + 200, y: 2100 // Increase y position to add more space }); background3.addChildAt(slot3, background3.children.length); // Add trees to the slots of background3 if (i === 0) { var tree13 = LK.getAsset('tree13', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree13); tree13.down = function (x, y, obj) { var duplicate = LK.getAsset('tree13', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 1) { var tree14 = LK.getAsset('tree14', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree14); tree14.down = function (x, y, obj) { var duplicate = LK.getAsset('tree14', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 2) { var tree15 = LK.getAsset('tree15', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree15); tree15.down = function (x, y, obj) { var duplicate = LK.getAsset('tree15', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } else if (i === 3) { var tree16 = LK.getAsset('tree16', { anchorX: 0.5, anchorY: 0.5, x: slot3.x, y: slot3.y }); background3.addChild(tree16); tree16.down = function (x, y, obj) { var duplicate = LK.getAsset('tree16', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); // Add timer text above the placed tree if (!duplicate.timerText) { duplicate.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(duplicate.timerText); } duplicate.timerText.x = duplicate.x; duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree duplicate.dragging = true; duplicate.data = obj; // Hide background3 and its components background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; background3.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } // Add timer text above the placed tree if (!this.timerText) { this.timerText = new Text2('5:00', { size: 50, fill: 0xFFFFFF }); this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center game.addChild(this.timerText); } this.timerText.x = this.x; this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree // Start countdown this.countdown = 300; // 5 minutes in seconds if (this.countdownInterval) { LK.clearInterval(this.countdownInterval); } this.countdownInterval = LK.setInterval(function () { this.countdown--; var minutes = Math.floor(this.countdown / 60); var seconds = this.countdown % 60; this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (this.countdown <= 0) { LK.clearInterval(this.countdownInterval); game.removeChild(this.timerText); this.timerText = null; // Reset timerText to null // Spawn 2 coins in front of the tree var coin1 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x - 50, y: this.y }); var coin2 = LK.getAsset('Coin', { anchorX: 0.5, anchorY: 0.5, x: this.x + 50, y: this.y }); game.addChild(coin1); game.addChild(coin2); } }.bind(this), 1000); }; }; } } scrollbutton3.down = function (x, y, obj) { this.dragging = true; this.data = obj; this.alpha = 0.5; }; scrollbutton3.up = function () { this.alpha = 1; this.dragging = false; this.data = null; }; scrollbutton3.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); // Limit the y position of the scrollbutton to the height of the scrollbar this.y = Math.max(Math.min(newPosition.y, scrollbar3.height - this.height / 2), this.height / 2); // Calculate the ratio of the scrollbutton's position to the scrollbar's height var ratio = (this.y - this.height / 2) / (scrollbar3.height - this.height); // Move the background3 up or down based on the ratio and the speed background3.y = -ratio * (background3.height - game.height); } }; var buildAsset = LK.getAsset('Build', { anchorX: 0.5, // Center the anchor point horizontally anchorY: 0.0, // Anchor point at the top x: 150, // Position on the left side of the screen y: 400 // Position directly below the pause button }); game.addChild(buildAsset); var button1Asset = LK.getAsset('button1', { anchorX: 0.5, anchorY: 0.0, x: 400, y: 0, visible: false // Initially hidden }); game.addChild(button1Asset); var button2Asset = LK.getAsset('button2', { anchorX: 0.5, anchorY: 0.0, x: button1Asset.x + button1Asset.width + 10, y: 0, visible: false // Initially hidden }); game.addChild(button2Asset); // Add text 'House' to button1 var button1Text = new Text2('House', { size: 80, fill: 0xFFFFFF }); button1Text.anchor.set(0.5, 0.5); // Center the text on the button button1Text.x = button1Asset.x; button1Text.y = button1Asset.y + button1Asset.height / 2; button1Text.visible = false; game.addChild(button1Text); // Add text 'Tree' to button2 var button2Text = new Text2('Tree', { size: 80, fill: 0xFFFFFF }); button2Text.anchor.set(0.5, 0.5); // Center the text on the button button2Text.x = button2Asset.x; button2Text.y = button2Asset.y + button2Asset.height / 2; button2Text.visible = false; game.addChild(button2Text); // Add score text to the top right corner var scoreText = new Text2('0', { size: 80, fill: 0xFFFFFF }); scoreText.anchor.set(1, 0); // Anchor to the top right corner scoreText.x = 2048; // Right edge of the screen scoreText.y = 0; // Top edge of the screen game.addChild(scoreText); // Function to update score function updateScore() { var score = 0; game.children.forEach(function (child) { if (child.assetId && child.assetId.startsWith('tree')) { score++; } }); scoreText.setText('Score: ' + score); } // Add click event to button2 to toggle visibility of background3, its slots, and scroll components button2Asset.down = function (x, y, obj) { // Toggle visibility of background3 and its components background3.visible = !background3.visible; game.children.forEach(function (child) { if (child.assetId === 'Grid') { child.visible = false; } }); scrollbar3.visible = !scrollbar3.visible; scrollbutton3.visible = !scrollbutton3.visible; background3.children.forEach(function (child) { child.visible = background3.visible; }); // Toggle visibility of background1 based on background2 and background3 visibility background1.visible = !(background2.visible || background3.visible); // Hide all grids when button2 is clicked game.children.forEach(function (child) { if (child.assetId === 'Grid' || child.assetId === 'background1') { child.visible = false; } }); }; // Add click event to button1 to toggle visibility of background2, its slots, and scroll components button1Asset.down = function (x, y, obj) { // Toggle visibility of background2 and its components background2.visible = !background2.visible; game.children.forEach(function (child) { if (child.assetId === 'Grid') { child.visible = false; } }); scrollbar.visible = !scrollbar.visible; scrollbutton.visible = !scrollbutton.visible; background2.children.forEach(function (child) { child.visible = background2.visible; }); // Toggle visibility of background1 based on background2 and background3 visibility background1.visible = !(background2.visible || background3.visible); // Hide all grids when button1 is clicked game.children.forEach(function (child) { if (child.assetId === 'Grid' || child.assetId === 'background1') { child.visible = false; } }); }; // Add click event to build asset to hide background2 and background3 with their components buildAsset.down = function (x, y, obj) { button1Asset.visible = !button1Asset.visible; button1Text.visible = !button1Text.visible; button2Asset.visible = !button2Asset.visible; button2Text.visible = !button2Text.visible; background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background3.visible = false; scrollbar3.visible = false; scrollbutton3.visible = false; }; var slotSpacing = 50; // Define the space between slots for (var i = 0; i < 4; i++) { var slot = LK.getAsset('Slot', { anchorX: 0.5, anchorY: 0.5, x: i * (slotSpacing + 450) + slotSpacing + 200, // Position slots with space between them y: 300 // Arbitrary y position }); background2.addChildAt(slot, background2.children.length); // Add house1 to the first slot on the left if (i === 0) { var house1 = LK.getAsset('house1', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house1); house1.down = function (x, y, obj) { var duplicate = LK.getAsset('house1', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); game.children.forEach(function (child) { if (child.assetId === 'Grid') { child.visible = true; } }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 1) { var house2 = LK.getAsset('house2', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house2); house2.down = function (x, y, obj) { var duplicate = LK.getAsset('house2', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 2) { var house3 = LK.getAsset('house3', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house3); house3.down = function (x, y, obj) { var duplicate = LK.getAsset('house3', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 3) { var house4 = LK.getAsset('house4', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house4); house4.down = function (x, y, obj) { var duplicate = LK.getAsset('house4', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } } // Add 4 slots below the first line of slots that are synced in background2 for (var i = 0; i < 4; i++) { var slot = LK.getAsset('Slot', { anchorX: 0.5, anchorY: 0.5, x: i * (slotSpacing + 450) + slotSpacing + 200, y: 900 // Increase y position to add more space }); background2.addChildAt(slot, background2.children.length); // Add house5 to the first slot in the second line if (i === 0) { var house5 = LK.getAsset('house5', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house5); house5.down = function (x, y, obj) { var duplicate = LK.getAsset('house5', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 1) { var house6 = LK.getAsset('house6', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house6); house6.down = function (x, y, obj) { var duplicate = LK.getAsset('house6', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 2) { var house7 = LK.getAsset('house7', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house7); house7.down = function (x, y, obj) { var duplicate = LK.getAsset('house7', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 3) { var house8 = LK.getAsset('house8', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house8); house8.down = function (x, y, obj) { var duplicate = LK.getAsset('house8', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } } // Add 4 slots below the second line of slots that are synced in background2 for (var i = 0; i < 4; i++) { var slot = LK.getAsset('Slot', { anchorX: 0.5, anchorY: 0.5, x: i * (slotSpacing + 450) + slotSpacing + 200, y: 1500 // Increase y position to add more space }); background2.addChildAt(slot, background2.children.length); // Add houses to the third line of slots if (i === 0) { var house9 = LK.getAsset('house9', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house9); house9.down = function (x, y, obj) { var duplicate = LK.getAsset('house9', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 1) { var house10 = LK.getAsset('house10', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house10); house10.down = function (x, y, obj) { var duplicate = LK.getAsset('house10', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 2) { var house11 = LK.getAsset('house11', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house11); house11.down = function (x, y, obj) { var duplicate = LK.getAsset('house11', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 3) { var house12 = LK.getAsset('house12', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house12); house12.down = function (x, y, obj) { var duplicate = LK.getAsset('house12', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } } // Add 4 slots below the third line of slots that are synced in background2 for (var i = 0; i < 4; i++) { var slot = LK.getAsset('Slot', { anchorX: 0.5, anchorY: 0.5, x: i * (slotSpacing + 450) + slotSpacing + 200, y: 2100 // Increase y position to add more space }); background2.addChildAt(slot, background2.children.length); // Add houses to the fourth line of slots if (i === 0) { var house13 = LK.getAsset('house13', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house13); house13.down = function (x, y, obj) { var duplicate = LK.getAsset('house13', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 1) { var house14 = LK.getAsset('house14', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house14); house14.down = function (x, y, obj) { var duplicate = LK.getAsset('house14', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 2) { var house15 = LK.getAsset('house15', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house15); house15.down = function (x, y, obj) { var duplicate = LK.getAsset('house15', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 3) { var house16 = LK.getAsset('house16', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house16); house16.down = function (x, y, obj) { var duplicate = LK.getAsset('house16', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } } // Add 4 slots below the forth line of slots that are synced in background2 for (var i = 0; i < 4; i++) { var slot = LK.getAsset('Slot', { anchorX: 0.5, anchorY: 0.5, x: i * (slotSpacing + 450) + slotSpacing + 200, y: 2700 // Increase y position to add more space }); background2.addChildAt(slot, background2.children.length); // Add house17 to the first slot in the fifth line if (i === 0) { var house18 = LK.getAsset('house18', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house18); house18.down = function (x, y, obj) { var duplicate = LK.getAsset('house18', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 1) { var house19 = LK.getAsset('house19', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house19); house19.down = function (x, y, obj) { var duplicate = LK.getAsset('house19', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 2) { var house20 = LK.getAsset('house20', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house20); house20.down = function (x, y, obj) { var duplicate = LK.getAsset('house20', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } else if (i === 3) { var house17 = LK.getAsset('house17', { anchorX: 0.5, anchorY: 0.5, x: slot.x, y: slot.y }); background2.addChild(house17); house17.down = function (x, y, obj) { var duplicate = LK.getAsset('house17', { anchorX: 0.5, anchorY: 0.5, x: x, y: y }); game.addChildAt(duplicate, game.getChildIndex(background2)); duplicate.dragging = true; duplicate.data = obj; // Hide background2 and its components background2.visible = false; scrollbar.visible = false; scrollbutton.visible = false; background2.children.forEach(function (child) { child.visible = false; }); duplicate.down = function (x, y, obj) { this.dragging = true; this.data = obj; }; duplicate.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); this.x = newPosition.x; this.y = newPosition.y; } }; duplicate.up = function () { this.dragging = false; this.data = null; // Snap to nearest grid var closestGrid = null; var minDistance = Infinity; game.children.forEach(function (child) { if (child.assetId === 'Grid') { var distance = Math.sqrt(Math.pow(child.x - this.x, 2) + Math.pow(child.y - this.y, 2)); if (distance < minDistance) { minDistance = distance; closestGrid = child; } } }, this); if (closestGrid) { this.x = closestGrid.x; this.y = closestGrid.y; } }; }; } } scrollbutton.down = function (x, y, obj) { this.dragging = true; this.data = obj; this.alpha = 0.5; }; scrollbutton.up = function () { this.alpha = 1; this.dragging = false; this.data = null; }; scrollbutton.move = function (x, y, obj) { if (this.dragging) { var newPosition = this.parent.toLocal(obj.global); // Limit the y position of the scrollbutton to the height of the scrollbar this.y = Math.max(Math.min(newPosition.y, scrollbar.height - this.height / 2), this.height / 2); // Calculate the ratio of the scrollbutton's position to the scrollbar's height var ratio = (this.y - this.height / 2) / (scrollbar.height - this.height); // Move the background2 up or down based on the ratio and the speed background2.y = -ratio * (background2.height - game.height); // Removed synchronization of scrollbar with background2 movement } }; // Removed up functionality from scrollbutton;
===================================================================
--- original.js
+++ change.js
@@ -167,8 +167,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -271,8 +282,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -370,8 +392,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -469,8 +502,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -580,8 +624,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -679,8 +734,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -778,8 +844,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -877,8 +954,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -988,8 +1076,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -1087,8 +1186,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -1186,8 +1296,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -1285,8 +1406,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -1397,8 +1529,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -1444,9 +1587,9 @@
size: 50,
fill: 0xFFFFFF
});
this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
- background2.addChild(this.timerText);
+ game.addChild(this.timerText);
}
this.timerText.x = this.x;
this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
// Start countdown
@@ -1497,8 +1640,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -1544,9 +1698,9 @@
size: 50,
fill: 0xFFFFFF
});
this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
- background2.addChild(this.timerText);
+ game.addChild(this.timerText);
}
this.timerText.x = this.x;
this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
// Start countdown
@@ -1597,8 +1751,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -1643,9 +1808,9 @@
size: 50,
fill: 0xFFFFFF
});
this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
- background2.addChild(this.timerText);
+ game.addChild(this.timerText);
}
this.timerText.x = this.x;
this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
// Start countdown
@@ -1696,8 +1861,19 @@
x: x,
y: y
});
game.addChildAt(duplicate, game.getChildIndex(background2));
+ // Add timer text above the placed tree
+ if (!duplicate.timerText) {
+ duplicate.timerText = new Text2('5:00', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
+ game.addChild(duplicate.timerText);
+ }
+ duplicate.timerText.x = duplicate.x;
+ duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
duplicate.dragging = true;
duplicate.data = obj;
// Hide background3 and its components
background3.visible = false;
@@ -1742,9 +1918,9 @@
size: 50,
fill: 0xFFFFFF
});
this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
- background2.addChild(this.timerText);
+ game.addChild(this.timerText);
}
this.timerText.x = this.x;
this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
// Start countdown
2D wreckage of wood, square, HD colors. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
House from the front facing the screen with big sign above it have description "SHOP", Hd colors
coin with colors, have "DA", hd colors. have black circles and black line for the "DA", between the 2 circles do small black lines all around. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Modern App Store icon, square with rounded corners, HD colors for a 2d game titled "The Collector" and with the description "about building houses and trees and decorations on a map to make it look like city, which then generate "DA" coins after a countdown timer expires. Players can collect these coins to increase their score, which they can then use to purchase more houses and trees and decorations from the shop button on the middle left side of the screen". with text on the middle top of the banner "the collector"!