User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bronzeScoreText.setText(lastBronzeScore);' Line Number: 2480
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'goldScoreText.setText(lastGoldScore);' Line Number: 2471
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'stoneScoreText.setText(lastStoneScore);' Line Number: 2462
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'stoneScoreText.setText(lastStoneScore);' Line Number: 2462
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'stoneScoreText.setText(lastStoneScore);' Line Number: 2462
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'silverScoreText.setText(lastSilverScore);' Line Number: 2453
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'silverScoreText.setText(lastSilverScore);' Line Number: 2453
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'silverScoreText.setText(lastSilverScore);' Line Number: 2453
/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1", { lastScores: { silver: 0, stone: 0, gold: 0, bronze: 0, crystal: 0, wood: 0 } }); /**** * Classes ****/ var Page0 = Container.expand(function () { var self = Container.call(this); // Get and automatically addChild to self asset with id 'woodarea' with the anchor point set to 0.5, 0.5 var background0 = self.attachAsset('background0', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, scaleX: 1.5, scaleY: 1.5 }); var woodarea = self.attachAsset('woodarea', { anchorX: 4.5, anchorY: 2.5, x: background0.x, y: background0.y }); self.addChild(woodarea); var stonearea = self.attachAsset('stonearea', { anchorX: 0.5, anchorY: 0.5, x: background0.x - 450, // Position stonearea to the right of woodarea y: background0.y - 300 }); self.addChild(stonearea); self.lastX = background0.x; self.lastY = background0.y; // Add drag functionality to the background1 image self.down = function (x, y, obj) { self.dragging = true; self.data = obj.data; self.initialClick = { x: x, y: y }; self.offset = { x: background0.x - x, y: background0.y - y }; }; self.up = function () { self.dragging = false; self.data = null; }; self.move = function (x, y, obj) { if (self.dragging) { // Check if we reached the Y position 1000 right now as we were not there before if (self.lastY <= 1000 && background0.y > 1000) { console.log("Background0 reached Y position 1000"); } // Check if woodarea reached the Y position 1500 right now as it was not there before if (self.lastY <= 1500 && woodarea.y > 1500) { console.log("Woodarea reached Y position 1500"); } // Check if we reached the X position 500 right now as we were not there before if (self.lastX <= 500 && background0.x > 500) { console.log("Background0 reached X position 500"); } // Check if we reached the X position 1500 right now as we were not there before if (self.lastX <= 1500 && background0.x > 1500) { console.log("Background0 reached X position 1500"); } var dx = x - self.initialClick.x; var dy = y - self.initialClick.y; background0.x = x + self.offset.x; background0.y = y + self.offset.y; woodarea.x = background0.x; // Sync woodarea's x position with background0 woodarea.y = background0.y; // Sync woodarea's y position with background0 stonearea.x = background0.x - 450; // Maintain initial offset from background0 stonearea.y = background0.y - 300; // Maintain initial offset from background0 gate1.x = background0.x; // Sync gate1's x position with background0 gate1.y = background0.y; // Sync gate1's y position with background0 gate2.x = background0.x; // Sync gate2's x position with background0 gate2.y = background0.y; // Sync gate2's y position with background0 gate3.x = background0.x; // Sync gate3's x position with background0 gate3.y = background0.y; // Sync gate3's y position with background0 gate4.x = background0.x; // Sync gate4's x position with background0 gate4.y = background0.y; // Sync gate4's y position with background0 gate5.x = background0.x; // Sync gate5's x position with background0 gate5.y = background0.y; // Sync gate5's y position with background0 gate6.x = background0.x; // Sync gate6's x position with background0 gate6.y = background0.y; // Sync gate6's y position with background0 self.initialClick = { x: x, y: y }; self.lastX = background0.x; self.lastY = background0.y; } }; // Get and automatically addChild to self asset with id 'gate1' with the anchor point set to 0.5, 0.5 var gate1 = self.attachAsset('gate1', { anchorX: 9.5, anchorY: 1.4, x: 1024, y: 1366 }); // Add click event to gate1 to navigate to Page1 gate1.down = function (x, y, obj) { // Navigate to Page1 // Save the last treestime when navigating away from Page1 storage.lastTreeTime = new Date().getTime(); saveScoresToStorage(); // Save scores before navigating page.visible = false; // Hide current page page = game.addChild(new Page1()); updateScoreTexts(); // Update score texts on new page }; // Get and automatically addChild to self asset with id 'gate2' with the anchor point set to 0.5, 0.5 var gate2 = self.attachAsset('gate2', { anchorX: 5.5, anchorY: 0.8, x: 1024, y: 1366 }); // Add click event to gate2 to navigate to Page2 gate2.down = function (x, y, obj) { // Navigate to Page2 saveStoneCooldowns(); // Save stone cooldowns before navigating away saveScoresToStorage(); // Save scores before navigating page.visible = false; // Hide current page page = game.addChild(new Page2()); updateScoreTexts(); // Update score texts on new page }; // Get and automatically addChild to self asset with id 'gate3' with the anchor point set to 0.5, 0.5 var gate3 = self.attachAsset('gate3', { anchorX: 2.4, anchorY: -3.5, x: 1024, y: 1366 }); // Add click event to gate3 to navigate to Page3 gate3.down = function (x, y, obj) { // Navigate to Page3 saveScoresToStorage(); // Save scores before navigating page.visible = false; // Hide current page page = game.addChild(new Page3()); updateScoreTexts(); // Update score texts on new page }; // Get and automatically addChild to self asset with id 'gate4' with the anchor point set to 0.5, 0.5 var gate4 = self.attachAsset('gate4', { anchorX: 9.8, anchorY: 9.8, x: 1024, y: 1366 }); gate4.x = background0.x; // Sync gate4's x position with background0 gate4.y = background0.y; // Sync gate4's y position with background0 // Add click event to gate4 to navigate to Page4 gate4.down = function (x, y, obj) { // Navigate to Page4 saveScoresToStorage(); // Save scores before navigating page.visible = false; // Hide current page page = game.addChild(new Page4()); updateScoreTexts(); // Update score texts on new page }; // Get and automatically addChild to self asset with id 'gate5' with the anchor point set to 0.5, 0.5 var gate5 = self.attachAsset('gate5', { anchorX: 3, anchorY: 7, x: 1024, y: 1366 }); gate5.x = background0.x; // Sync gate5's x position with background0 gate5.y = background0.y; // Sync gate5's y position with background0 // Add click event to gate5 to navigate to Page5 gate5.down = function (x, y, obj) { // Navigate to Page5 saveScoresToStorage(); // Save scores before navigating page.visible = false; // Hide current page page = game.addChild(new Page5()); updateScoreTexts(); // Update score texts on new page }; // Get and automatically addChild to self asset with id 'gate6' with the anchor point set to 0.5, 0.5 var gate6 = self.attachAsset('gate6', { anchorX: -6, anchorY: 7.5, x: 1024, y: 1366 }); gate6.x = background0.x; // Sync gate6's x position with background0 gate6.y = background0.y; // Sync gate6's y position with background0 // Add click event to gate6 to navigate to Page1 gate6.down = function (x, y, obj) { // Navigate to Page6 saveScoresToStorage(); // Save scores before navigating page.visible = false; // Hide current page page = game.addChild(new Page6()); updateScoreTexts(); // Update score texts on new page }; }); // Create a Page1 class by using the LK expand method to extend Container. var Page1 = Container.expand(function () { var self = Container.call(this); // Restore the last treestime when returning to Page1 if (storage.lastTreeTime) { var currentTime = new Date().getTime(); var timeElapsed = currentTime - storage.lastTreeTime; updateTreeCooldowns(timeElapsed); storage.lastTreeTime = currentTime; // Update lastTreeTime to current time } var background1 = self.attachAsset('background1', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); var wall1 = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 1.0, x: 1024, // Center horizontally y: 2732 // Position at the bottom }); // Add map asset to Page1 below the pause button var map = self.attachAsset('Map', { anchorX: 0.5, anchorY: 0.5, x: 100, // Set position directly below the pause button y: 300 // Adjusted position to be directly below the pause button }); self.addChild(map); var mapText = new Text2('MAP', { size: 90, fill: 0xFFA500 // Orange color }); mapText.anchor.set(0.5, 0); mapText.x = map.x; mapText.y = map.y + map.height / 2 + 2; // Position directly below and closer to the map asset self.addChild(mapText); var build = self.attachAsset('Build', { anchorX: 0.5, anchorY: 0.5, x: map.x, y: mapText.y + mapText.height / 2 + 150 // Move 150 units further down below the MAP text }); self.addChild(build); var buildText = new Text2('BUILD', { size: 80, fill: 0xFFA500 // Orange color }); buildText.anchor.set(0.5, 0); buildText.x = build.x; buildText.y = build.y + build.height / 2 + 2; // Position directly below and closer to the build asset self.addChild(buildText); // Add click event to build to navigate to Page7 build.down = function (x, y, obj) { // Navigate to Page7 page.visible = false; // Hide current page page = game.addChild(new Page7()); }; map.down = function (x, y, obj) { // Navigate to Page0 page.visible = false; // Hide current page page = game.addChild(new Page0()); }; // Add wood asset to Page1 var tree1 = self.attachAsset('tree1', { anchorX: 0.5, anchorY: 0.5, x: 1500, // Center horizontally y: 500 // Position in the middle of the screen }); tree1.clickCount = 0; tree1.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree1.timetext.anchor.set(0.5, 0.5); tree1.timetext.x = tree1.x; tree1.timetext.y = tree1.y; tree1.timetext.visible = false; // Initially hidden self.addChild(tree1.timetext); tree1.down = function (x, y, obj) { handleTreeClick(tree1); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text storage.lastScores.wood = wood.clickCount; // Persist wood score } }; var tree2 = self.attachAsset('tree2', { anchorX: 0.5, anchorY: 0.5, x: 1200, // Position tree2 to the left of tree1 y: 500 // Align vertically with tree1 }); tree2.clickCount = 0; tree2.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree2.timetext.anchor.set(0.5, 0.5); tree2.timetext.x = tree2.x; tree2.timetext.y = tree2.y; tree2.timetext.visible = false; // Initially hidden self.addChild(tree2.timetext); tree2.down = function (x, y, obj) { handleTreeClick(tree2); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; self.addChild(tree2); var tree3 = self.attachAsset('tree3', { anchorX: 0.5, anchorY: 0.5, x: 900, // Position tree3 to the left of tree2 y: 500 // Align vertically with tree2 }); tree3.clickCount = 0; tree3.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree3.timetext.anchor.set(0.5, 0.5); tree3.timetext.x = tree3.x; tree3.timetext.y = tree3.y; tree3.timetext.visible = false; // Initially hidden self.addChild(tree3.timetext); tree3.down = function (x, y, obj) { handleTreeClick(tree3); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; self.addChild(tree3); var tree4 = self.attachAsset('tree4', { anchorX: 0.5, anchorY: 0.5, x: 600, // Position tree4 to the left of tree3 y: 500 // Align vertically with tree3 }); tree4.clickCount = 0; tree4.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree4.timetext.anchor.set(0.5, 0.5); tree4.timetext.x = tree4.x; tree4.timetext.y = tree4.y; tree4.timetext.visible = false; // Initially hidden self.addChild(tree4.timetext); tree4.down = function (x, y, obj) { handleTreeClick(tree4); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; self.addChild(tree4); var tree5 = self.attachAsset('tree5', { anchorX: 0.5, anchorY: 0.5, x: 1500, // Align horizontally with tree1 y: 900 // Position tree5 below tree1 }); tree5.clickCount = 0; tree5.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree5.timetext.anchor.set(0.5, 0.5); tree5.timetext.x = tree5.x; tree5.timetext.y = tree5.y; tree5.timetext.visible = false; // Initially hidden self.addChild(tree5.timetext); tree5.down = function (x, y, obj) { handleTreeClick(tree5); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree6 = self.attachAsset('tree6', { anchorX: 0.5, anchorY: 0.5, x: 1200, // Align horizontally with tree2 y: 900 // Position tree6 below tree2 }); tree6.clickCount = 0; tree6.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree6.timetext.anchor.set(0.5, 0.5); tree6.timetext.x = tree6.x; tree6.timetext.y = tree6.y; tree6.timetext.visible = false; // Initially hidden self.addChild(tree6.timetext); tree6.down = function (x, y, obj) { handleTreeClick(tree6); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree7 = self.attachAsset('tree7', { anchorX: 0.5, anchorY: 0.5, x: 900, // Align horizontally with tree3 y: 900 // Position tree7 below tree3 }); tree7.clickCount = 0; tree7.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree7.timetext.anchor.set(0.5, 0.5); tree7.timetext.x = tree7.x; tree7.timetext.y = tree7.y; tree7.timetext.visible = false; // Initially hidden self.addChild(tree7.timetext); tree7.down = function (x, y, obj) { handleTreeClick(tree7); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree8 = self.attachAsset('tree8', { anchorX: 0.5, anchorY: 0.5, x: 600, // Align horizontally with tree4 y: 900 // Position tree8 below tree4 }); tree8.clickCount = 0; tree8.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree8.timetext.anchor.set(0.5, 0.5); tree8.timetext.x = tree8.x; tree8.timetext.y = tree8.y; tree8.timetext.visible = false; // Initially hidden self.addChild(tree8.timetext); tree8.down = function (x, y, obj) { handleTreeClick(tree8); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree9 = self.attachAsset('tree9', { anchorX: 0.5, anchorY: 0.5, x: 1500, // Align horizontally with tree5 y: 1300 // Position tree9 below tree5 }); tree9.clickCount = 0; tree9.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree9.timetext.anchor.set(0.5, 0.5); tree9.timetext.x = tree9.x; tree9.timetext.y = tree9.y; tree9.timetext.visible = false; // Initially hidden self.addChild(tree9.timetext); tree9.down = function (x, y, obj) { handleTreeClick(tree9); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree10 = self.attachAsset('tree10', { anchorX: 0.5, anchorY: 0.5, x: 1200, // Align horizontally with tree6 y: 1300 // Position tree10 below tree6 }); tree10.clickCount = 0; tree10.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree10.timetext.anchor.set(0.5, 0.5); tree10.timetext.x = tree10.x; tree10.timetext.y = tree10.y; tree10.timetext.visible = false; // Initially hidden self.addChild(tree10.timetext); tree10.down = function (x, y, obj) { handleTreeClick(tree10); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree11 = self.attachAsset('tree11', { anchorX: 0.5, anchorY: 0.5, x: 900, // Align horizontally with tree7 y: 1300 // Position tree11 below tree7 }); tree11.clickCount = 0; tree11.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree11.timetext.anchor.set(0.5, 0.5); tree11.timetext.x = tree11.x; tree11.timetext.y = tree11.y; tree11.timetext.visible = false; // Initially hidden self.addChild(tree11.timetext); tree11.down = function (x, y, obj) { handleTreeClick(tree11); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree12 = self.attachAsset('tree12', { anchorX: 0.5, anchorY: 0.5, x: 600, // Align horizontally with tree8 y: 1300 // Position tree12 below tree8 }); tree12.clickCount = 0; tree12.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree12.timetext.anchor.set(0.5, 0.5); tree12.timetext.x = tree12.x; tree12.timetext.y = tree12.y; tree12.timetext.visible = false; // Initially hidden self.addChild(tree12.timetext); tree12.down = function (x, y, obj) { handleTreeClick(tree12); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree13 = self.attachAsset('tree13', { anchorX: 0.5, anchorY: 0.5, x: 1500, // Align horizontally with tree9 y: 1700 // Position tree13 below tree9 }); tree13.clickCount = 0; tree13.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree13.timetext.anchor.set(0.5, 0.5); tree13.timetext.x = tree13.x; tree13.timetext.y = tree13.y; tree13.timetext.visible = false; // Initially hidden self.addChild(tree13.timetext); tree13.down = function (x, y, obj) { handleTreeClick(tree13); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree14 = self.attachAsset('tree14', { anchorX: 0.5, anchorY: 0.5, x: 1200, // Align horizontally with tree10 y: 1700 // Position tree14 below tree10 }); tree14.clickCount = 0; tree14.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree14.timetext.anchor.set(0.5, 0.5); tree14.timetext.x = tree14.x; tree14.timetext.y = tree14.y; tree14.timetext.visible = false; // Initially hidden self.addChild(tree14.timetext); tree14.down = function (x, y, obj) { handleTreeClick(tree14); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree15 = self.attachAsset('tree15', { anchorX: 0.5, anchorY: 0.5, x: 900, // Align horizontally with tree11 y: 1700 // Position tree15 below tree11 }); tree15.clickCount = 0; tree15.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree15.timetext.anchor.set(0.5, 0.5); tree15.timetext.x = tree15.x; tree15.timetext.y = tree15.y; tree15.timetext.visible = false; // Initially hidden self.addChild(tree15.timetext); tree15.down = function (x, y, obj) { handleTreeClick(tree15); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; var tree16 = self.attachAsset('tree16', { anchorX: 0.5, anchorY: 0.5, x: 600, // Align horizontally with tree12 y: 1700 // Position tree16 below tree12 }); tree16.clickCount = 0; tree16.timetext = new Text2('3:00', { // Add timetext size: 80, fill: 0x8B4513 }); tree16.timetext.anchor.set(0.5, 0.5); tree16.timetext.x = tree16.x; tree16.timetext.y = tree16.y; tree16.timetext.visible = false; // Initially hidden self.addChild(tree16.timetext); tree16.down = function (x, y, obj) { handleTreeClick(tree16); if (page instanceof Page1) { wood.clickCount += 5; // Increase wood score by 5 woodScoreText.setText(wood.clickCount); // Update wood score text } }; self.addChild(tree1); var wood = self.attachAsset('wood', { anchorX: 0.5, anchorY: 0.5, x: 1902, // Position wood in the middle of the screen y: 2510 // Position wood below the trees }); wood.clickCount = 0; // Initialize wood score independently for Page1 // Add woodScoreText to Page1 var woodScoreText = new Text2('0', { size: 70, fill: 0x471e00 }); woodScoreText.anchor.set(1, 0.5); woodScoreText.x = 1800; // Position woodScoreText on the screen woodScoreText.y = 2510; // Align vertically with the wood asset self.addChild(woodScoreText); var silver = self.attachAsset('silver', { anchorX: 0.5, anchorY: 0.5, x: 1902, // Align horizontally with wood y: 2660 // Position silver directly below the wood }); // Add text for silver score beside silver asset var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); silver.clickCount = 0; silver.down = function (x, y, obj) { statueText.setText(totalStatueScore); // Update statue text with total statue score }; silverScoreText.anchor.set(1, 0.5); silverScoreText.x = silver.x - 90; // Position text to the left of the silver silverScoreText.y = silver.y; self.addChild(silverScoreText); var stone = self.attachAsset('stone', { anchorX: 0.5, anchorY: 0.5, x: 1220, // Position stone in the middle of the screen y: 2510 // Position stone below the wood }); // Add text for stone score beside stone asset var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); stone.clickCount = 0; stone.down = function (x, y, obj) { statueText.setText(totalStatueScore); // Update statue text with total statue score }; stoneScoreText.anchor.set(1, 0.5); stoneScoreText.x = stone.x - 90; // Position text to the left of the stone stoneScoreText.y = stone.y; self.addChild(stoneScoreText); var gold = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5, x: 1220, // Align horizontally with stone y: 2660 // Position gold below the stone }); // Add text for gold score beside gold asset var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); gold.clickCount = 0; gold.down = function (x, y, obj) { statueText.setText(totalStatueScore); // Update statue text with total statue score }; goldScoreText.anchor.set(1, 0.5); goldScoreText.x = gold.x - 90; // Position text to the left of the gold goldScoreText.y = gold.y; self.addChild(goldScoreText); var bronze = self.attachAsset('bronze', { anchorX: 0.5, anchorY: 0.5, x: 595, // Position bronze in the middle of the screen y: 2510 // Position bronze above the stone }); // Add text for bronze score beside bronze asset var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); bronze.clickCount = 0; bronze.down = function (x, y, obj) { statueText.setText(totalStatueScore); // Update statue text with total statue score }; bronzeScoreText.anchor.set(1, 0.5); bronzeScoreText.x = bronze.x - 90; // Position text to the left of the bronze bronzeScoreText.y = bronze.y; self.addChild(bronzeScoreText); var crystal = self.attachAsset('crystal', { anchorX: 0.5, anchorY: 0.5, x: 595, // Align horizontally with bronze y: 2660 // Position crystal below the bronze }); // Add text for crystal score beside crystal asset var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); crystal.clickCount = 0; crystal.down = function (x, y, obj) { statueText.setText(totalStatueScore); // Update statue text with total statue score }; crystalScoreText.anchor.set(1, 0.5); crystalScoreText.x = crystal.x - 90; // Position text to the left of the crystal crystalScoreText.y = crystal.y; self.addChild(crystalScoreText); }); var Page2 = Container.expand(function () { var self = Container.call(this); restoreStoneCooldowns(); // Restore stone cooldowns when navigating to Page2 // Add map asset to Page2 below the pause button var background2 = self.attachAsset('background2', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0, scaleX: 2050 / 2048, // Match width of background1 scaleY: 2420 / 2732 // Match height of background1 }); var wall1 = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 1.0, x: 1024, // Center horizontally y: 2732 // Position at the bottom }); self.addChild(wall1); // Add map asset to Page2 below the pause button var map = self.attachAsset('Map', { anchorX: 0.5, anchorY: 0.5, x: 100, y: 300 }); self.addChild(map); var mapText = new Text2('MAP', { size: 90, fill: 0xFFA500 // Orange color }); mapText.anchor.set(0.5, 0); mapText.x = map.x; mapText.y = map.y + map.height / 2 + 2; // Position directly below and closer to the map asset self.addChild(mapText); var build = self.attachAsset('Build', { anchorX: 0.5, anchorY: 0.5, x: map.x, y: mapText.y + mapText.height / 2 + 150 // Move 150 units further down below the MAP text }); self.addChild(build); var buildText = new Text2('BUILD', { size: 80, fill: 0xFFA500 // Orange color }); buildText.anchor.set(0.5, 0); buildText.x = build.x; buildText.y = build.y + build.height / 2 + 2; // Position directly below and closer to the build asset self.addChild(buildText); map.down = function (x, y, obj) { // Navigate to Page0 game.removeChild(page); page = game.addChild(new Page0()); }; // Add click event to build to navigate to Page7 build.down = function (x, y, obj) { // Navigate to Page7 game.removeChild(page); page = game.addChild(new Page7()); }; // Add resources and score similar to Page1 var wood = self.attachAsset('wood', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2510 }); self.addChild(wood); var woodScoreText = new Text2('0', { size: 70, fill: 0x471e00 }); woodScoreText.anchor.set(1, 0.5); woodScoreText.x = 1800; woodScoreText.y = 2510; self.addChild(woodScoreText); var silver = self.attachAsset('silver', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2660 }); self.addChild(silver); var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); silverScoreText.anchor.set(1, 0.5); silverScoreText.x = silver.x - 90; silverScoreText.y = silver.y; self.addChild(silverScoreText); var stone = self.attachAsset('stone', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2510 }); stone.clickCount = 0; // Initialize stone score independently for Page2 self.addChild(stone); var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); stoneScoreText.anchor.set(1, 0.5); stoneScoreText.x = stone.x - 90; // Position text to the left of the stone stoneScoreText.y = stone.y; self.addChild(stoneScoreText); var stone1 = self.attachAsset('stone1', { anchorX: 0.5, anchorY: 0.5, x: 1260, y: 1860 }); stone1.down = function (x, y, obj) { if (page instanceof Page2) { stone.clickCount += 5; // Increase stone score by 5 stoneScoreText.setText(stone.clickCount); // Update stone score text stone1.clickCount = (stone1.clickCount || 0) + 1; if (stone1.clickCount >= 3) { stone1.visible = false; // Hide stone1 after 3 clicks stone1TimeText.visible = true; // Make timetext visible var cooldown = 180; // 3 minutes in seconds var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone1TimeText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone1.clickCount = 0; // Reset click count stone1.visible = true; // Make stone visible again stone1TimeText.visible = false; // Hide timetext } }, 1000, true); // Decrease every second, continue even when page is not active } } }; var stone1TimeText = new Text2('3:00', { size: 80, fill: 0xffffff // White color }); stone1TimeText.anchor.set(0.5, 0.5); stone1TimeText.x = stone1.x; stone1TimeText.y = stone1.y; stone1TimeText.visible = false; // Make timetext invisible self.addChild(stone1TimeText); self.addChild(stone1); var stone2 = self.attachAsset('stone2', { anchorX: 0.5, anchorY: 0.5, x: 1660, y: 2150 }); stone2.down = function (x, y, obj) { if (page instanceof Page2) { stone.clickCount += 5; // Increase stone score by 5 stoneScoreText.setText(stone.clickCount); // Update stone score text stone2.clickCount = (stone2.clickCount || 0) + 1; if (stone2.clickCount >= 3) { stone2.visible = false; // Hide stone2 after 3 clicks stone2TimeText.visible = true; // Make timetext visible var cooldown = 180; // 3 minutes in seconds var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone2TimeText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone2.clickCount = 0; // Reset click count stone2.visible = true; // Make stone visible again stone2TimeText.visible = false; // Hide timetext } }, 1000, true); // Decrease every second, continue even when page is not active } } }; var stone2TimeText = new Text2('3:00', { size: 80, fill: 0xffffff // White color }); stone2TimeText.anchor.set(0.5, 0.5); stone2TimeText.x = stone2.x; stone2TimeText.y = stone2.y; stone2TimeText.visible = false; // Make timetext invisible self.addChild(stone2TimeText); self.addChild(stone2); var stone3 = self.attachAsset('stone3', { anchorX: 0.5, anchorY: 0.5, x: 600, y: 2290 }); stone3.down = function (x, y, obj) { if (page instanceof Page2) { stone.clickCount += 5; // Increase stone score by 5 stoneScoreText.setText(stone.clickCount); // Update stone score text stone3.clickCount = (stone3.clickCount || 0) + 1; if (stone3.clickCount >= 3) { stone3.visible = false; // Hide stone3 after 3 clicks stone3TimeText.visible = true; // Make timetext visible var cooldown = 180; // 3 minutes in seconds var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone3TimeText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone3.clickCount = 0; // Reset click count stone3.visible = true; // Make stone visible again stone3TimeText.visible = false; // Hide timetext } }, 1000, true); // Decrease every second, continue even when page is not active } } }; var stone3TimeText = new Text2('3:00', { size: 80, fill: 0xffffff // White color }); stone3TimeText.anchor.set(0.5, 0.5); stone3TimeText.x = stone3.x; stone3TimeText.y = stone3.y; stone3TimeText.visible = false; // Make timetext invisible self.addChild(stone3TimeText); self.addChild(stone3); var stone4 = self.attachAsset('stone4', { anchorX: 0.5, anchorY: 0.5, x: 500, y: 1720 }); stone4.down = function (x, y, obj) { if (page instanceof Page2) { stone.clickCount += 5; // Increase stone score by 5 stoneScoreText.setText(stone.clickCount); // Update stone score text stone4.clickCount = (stone4.clickCount || 0) + 1; if (stone4.clickCount >= 3) { stone4.visible = false; // Hide stone4 after 3 clicks stone4TimeText.visible = true; // Make timetext visible var cooldown = 180; // 3 minutes in seconds var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone4TimeText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone4.clickCount = 0; // Reset click count stone4.visible = true; // Make stone visible again stone4TimeText.visible = false; // Hide timetext } }, 1000, true); // Decrease every second, continue even when page is not active } } }; var stone4TimeText = new Text2('3:00', { size: 80, fill: 0xffffff // White color }); stone4TimeText.anchor.set(0.5, 0.5); stone4TimeText.x = stone4.x; stone4TimeText.y = stone4.y; stone4TimeText.visible = false; // Make timetext invisible self.addChild(stone4TimeText); self.addChild(stone4); var stone5 = self.attachAsset('stone5', { anchorX: 0.5, anchorY: 0.5, x: 300, y: 2250 }); stone5.down = function (x, y, obj) { if (page instanceof Page2) { stone.clickCount += 5; // Increase stone score by 5 stoneScoreText.setText(stone.clickCount); // Update stone score text stone5.clickCount = (stone5.clickCount || 0) + 1; if (stone5.clickCount >= 3) { stone5.visible = false; // Hide stone5 after 3 clicks stone5TimeText.visible = true; // Make timetext visible var cooldown = 180; // 3 minutes in seconds var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone5TimeText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone5.clickCount = 0; // Reset click count stone5.visible = true; // Make stone visible again stone5TimeText.visible = false; // Hide timetext } }, 1000, true); // Decrease every second, continue even when page is not active } } }; var stone5TimeText = new Text2('3:00', { size: 80, fill: 0xffffff // White color }); stone5TimeText.anchor.set(0.5, 0.5); stone5TimeText.x = stone5.x; stone5TimeText.y = stone5.y; stone5TimeText.visible = false; // Make timetext invisible self.addChild(stone5TimeText); self.addChild(stone5); var stone6 = self.attachAsset('stone6', { anchorX: 0.5, anchorY: 0.5, x: 1120, y: 2300 }); stone6.down = function (x, y, obj) { if (page instanceof Page2) { stone.clickCount += 5; // Increase stone score by 5 stoneScoreText.setText(stone.clickCount); // Update stone score text stone6.clickCount = (stone6.clickCount || 0) + 1; if (stone6.clickCount >= 3) { stone6.visible = false; // Hide stone6 after 3 clicks stone6TimeText.visible = true; // Make timetext visible var cooldown = 180; // 3 minutes in seconds var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone6TimeText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone6.clickCount = 0; // Reset click count stone6.visible = true; // Make stone visible again stone6TimeText.visible = false; // Hide timetext } }, 1000, true); // Decrease every second, continue even when page is not active } } }; var stone6TimeText = new Text2('3:00', { size: 80, fill: 0xffffff // White color }); stone6TimeText.anchor.set(0.5, 0.5); stone6TimeText.x = stone6.x; stone6TimeText.y = stone6.y; stone6TimeText.visible = false; // Make timetext invisible self.addChild(stone6TimeText); self.addChild(stone6); var stone7 = self.attachAsset('stone7', { anchorX: 0.5, anchorY: 0.5, x: 770, y: 1720 }); stone7.down = function (x, y, obj) { if (page instanceof Page2) { stone.clickCount += 5; // Increase stone score by 5 stoneScoreText.setText(stone.clickCount); // Update stone score text stone7.clickCount = (stone7.clickCount || 0) + 1; if (stone7.clickCount >= 3) { stone7.visible = false; // Hide stone7 after 3 clicks stone7TimeText.visible = true; // Make timetext visible var cooldown = 180; // 3 minutes in seconds var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone7TimeText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone7.clickCount = 0; // Reset click count stone7.visible = true; // Make stone visible again stone7TimeText.visible = false; // Hide timetext } }, 1000, true); // Decrease every second, continue even when page is not active } } }; var stone7TimeText = new Text2('3:00', { size: 80, fill: 0xffffff // White color }); stone7TimeText.anchor.set(0.5, 0.5); stone7TimeText.x = stone7.x; stone7TimeText.y = stone7.y; stone7TimeText.visible = false; // Make timetext invisible self.addChild(stone7TimeText); self.addChild(stone7); var stone8 = self.attachAsset('stone8', { anchorX: 0.5, anchorY: 0.5, x: 1560, y: 2020 }); stone8.down = function (x, y, obj) { if (page instanceof Page2) { stone.clickCount += 5; // Increase stone score by 5 stoneScoreText.setText(stone.clickCount); // Update stone score text stone8.clickCount = (stone8.clickCount || 0) + 1; if (stone8.clickCount >= 3) { stone8.visible = false; // Hide stone8 after 3 clicks stone8TimeText.visible = true; // Make timetext visible var cooldown = 180; // 3 minutes in seconds var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone8TimeText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone8.clickCount = 0; // Reset click count stone8.visible = true; // Make stone visible again stone8TimeText.visible = false; // Hide timetext } }, 1000, true); // Decrease every second, continue even when page is not active } } }; var stone8TimeText = new Text2('3:00', { size: 80, fill: 0xffffff // White color }); stone8TimeText.anchor.set(0.5, 0.5); stone8TimeText.x = stone8.x; stone8TimeText.y = stone8.y; stone8TimeText.visible = false; // Make timetext invisible self.addChild(stone8TimeText); self.addChild(stone8); var stone9 = self.attachAsset('stone9', { anchorX: 0.5, anchorY: 0.5, x: 1600, y: 2320 }); stone9.down = function (x, y, obj) { if (page instanceof Page2) { stone.clickCount += 5; // Increase stone score by 5 stoneScoreText.setText(stone.clickCount); // Update stone score text stone9.clickCount = (stone9.clickCount || 0) + 1; if (stone9.clickCount >= 3) { stone9.visible = false; // Hide stone9 after 3 clicks stone9TimeText.visible = true; // Make timetext visible var cooldown = 180; // 3 minutes in seconds var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone9TimeText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone9.clickCount = 0; // Reset click count stone9.visible = true; // Make stone visible again stone9TimeText.visible = false; // Hide timetext } }, 1000, true); // Decrease every second, continue even when page is not active } } }; var stone9TimeText = new Text2('3:00', { size: 80, fill: 0xffffff // White color }); stone9TimeText.anchor.set(0.5, 0.5); stone9TimeText.x = stone9.x; stone9TimeText.y = stone9.y; stone9TimeText.visible = false; // Make timetext invisible self.addChild(stone9TimeText); self.addChild(stone9); var stone10 = self.attachAsset('stone10', { anchorX: 0.5, anchorY: 0.5, x: 1100, y: 2050 }); stone10.down = function (x, y, obj) { if (page instanceof Page2) { stone.clickCount += 5; // Increase stone score by 5 stoneScoreText.setText(stone.clickCount); // Update stone score text stone10.clickCount = (stone10.clickCount || 0) + 1; if (stone10.clickCount >= 3) { stone10.visible = false; // Hide stone10 after 3 clicks stone10TimeText.visible = true; // Make timetext visible var cooldown = 180; // 3 minutes in seconds var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone10TimeText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone10.clickCount = 0; // Reset click count stone10.visible = true; // Make stone visible again stone10TimeText.visible = false; // Hide timetext } }, 1000, true); // Decrease every second, continue even when page is not active } } }; var stone10TimeText = new Text2('3:00', { size: 80, fill: 0xffffff // White color }); stone10TimeText.anchor.set(0.5, 0.5); stone10TimeText.x = stone10.x; stone10TimeText.y = stone10.y; stone10TimeText.visible = false; // Make timetext invisible self.addChild(stone10TimeText); self.addChild(stone10); var gold = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2660 }); self.addChild(gold); var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); goldScoreText.anchor.set(1, 0.5); goldScoreText.x = gold.x - 90; goldScoreText.y = gold.y; self.addChild(goldScoreText); var bronze = self.attachAsset('bronze', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2510 }); self.addChild(bronze); var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); bronzeScoreText.anchor.set(1, 0.5); bronzeScoreText.x = bronze.x - 90; bronzeScoreText.y = bronze.y; self.addChild(bronzeScoreText); var crystal = self.attachAsset('crystal', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2660 }); self.addChild(crystal); var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); crystalScoreText.anchor.set(1, 0.5); crystalScoreText.x = crystal.x - 90; crystalScoreText.y = crystal.y; self.addChild(crystalScoreText); }); var Page3 = Container.expand(function () { var self = Container.call(this); var wall1 = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 1.0, x: 1024, // Center horizontally y: 2732 // Position at the bottom }); wall1.visible = true; // Add resources and score similar to Page1 var wood = self.attachAsset('wood', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2510 }); self.addChild(wood); var woodScoreText = new Text2('0', { size: 70, fill: 0x471e00 }); woodScoreText.anchor.set(1, 0.5); woodScoreText.x = 1800; woodScoreText.y = 2510; self.addChild(woodScoreText); var silver = self.attachAsset('silver', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2660 }); self.addChild(silver); var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); silverScoreText.anchor.set(1, 0.5); silverScoreText.x = silver.x - 90; silverScoreText.y = silver.y; self.addChild(silverScoreText); var stone = self.attachAsset('stone', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2510 }); self.addChild(stone); var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); stoneScoreText.anchor.set(1, 0.5); stoneScoreText.x = stone.x - 90; stoneScoreText.y = stone.y; self.addChild(stoneScoreText); var gold = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2660 }); self.addChild(gold); var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); goldScoreText.anchor.set(1, 0.5); goldScoreText.x = gold.x - 90; goldScoreText.y = gold.y; self.addChild(goldScoreText); var bronze = self.attachAsset('bronze', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2510 }); bronze.clickCount = 0; // Initialize bronze score independently for Page3 self.addChild(bronze); var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); bronzeScoreText.anchor.set(1, 0.5); bronzeScoreText.x = bronze.x - 90; bronzeScoreText.y = bronze.y; self.addChild(bronzeScoreText); var crystal = self.attachAsset('crystal', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2660 }); self.addChild(crystal); var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); crystalScoreText.anchor.set(1, 0.5); crystalScoreText.x = crystal.x - 90; crystalScoreText.y = crystal.y; self.addChild(crystalScoreText); // Add map asset to Page3 below the pause button var background3 = self.attachAsset('background3', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0, scaleX: 2050 / 2048, // Match width of background1 scaleY: 2420 / 2732 // Match height of background1 }); // Add map asset to Page3 below the pause button var map = self.attachAsset('Map', { anchorX: 0.5, anchorY: 0.5, x: 100, y: 300 }); self.addChild(map); var mapText = new Text2('MAP', { size: 90, fill: 0xFFA500 // Orange color }); mapText.anchor.set(0.5, 0); mapText.x = map.x; mapText.y = map.y + map.height / 2 + 2; // Position directly below and closer to the map asset self.addChild(mapText); var build = self.attachAsset('Build', { anchorX: 0.5, anchorY: 0.5, x: map.x, y: mapText.y + mapText.height / 2 + 150 // Move 150 units further down below the MAP text }); self.addChild(build); var buildText = new Text2('BUILD', { size: 80, fill: 0xFFA500 // Orange color }); buildText.anchor.set(0.5, 0); buildText.x = build.x; buildText.y = build.y + build.height / 2 + 2; // Position directly below and closer to the build asset self.addChild(buildText); map.down = function (x, y, obj) { // Navigate to Page0 game.removeChild(page); page = game.addChild(new Page0()); }; // Add click event to build to navigate to Page7 build.down = function (x, y, obj) { // Navigate to Page7 game.removeChild(page); page = game.addChild(new Page7()); }; // Add resources and score similar to Page1 var wood = self.attachAsset('wood', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2510 }); self.addChild(wood); var silver = self.attachAsset('silver', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2660 }); self.addChild(silver); var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); silverScoreText.anchor.set(1, 0.5); silverScoreText.x = silver.x - 90; silverScoreText.y = silver.y; self.addChild(silverScoreText); var stone = self.attachAsset('stone', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2510 }); self.addChild(stone); var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); stoneScoreText.anchor.set(1, 0.5); stoneScoreText.x = stone.x - 90; stoneScoreText.y = stone.y; self.addChild(stoneScoreText); var gold = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2660 }); self.addChild(gold); var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); goldScoreText.anchor.set(1, 0.5); goldScoreText.x = gold.x - 90; goldScoreText.y = gold.y; self.addChild(goldScoreText); var bronze = self.attachAsset('bronze', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2510 }); self.addChild(bronze); var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); bronzeScoreText.anchor.set(1, 0.5); bronzeScoreText.x = bronze.x - 90; bronzeScoreText.y = bronze.y; self.addChild(bronzeScoreText); var crystal = self.attachAsset('crystal', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2660 }); self.addChild(crystal); var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); crystalScoreText.anchor.set(1, 0.5); crystalScoreText.x = crystal.x - 90; crystalScoreText.y = crystal.y; self.addChild(crystalScoreText); }); var Page4 = Container.expand(function () { var self = Container.call(this); // Add resources and score similar to Page1 var wood = self.attachAsset('wood', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2510 // Position wood below the trees }); self.addChild(wood); var woodScoreText = new Text2('0', { size: 70, fill: 0x471e00 }); woodScoreText.anchor.set(1, 0.5); woodScoreText.x = 1800; // Position woodScoreText on the screen woodScoreText.y = 2510; // Align vertically with the wood asset self.addChild(woodScoreText); var silver = self.attachAsset('silver', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2660 // Position silver directly below the wood }); silver.clickCount = 0; // Initialize silver score independently for Page4 self.addChild(silver); var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); silverScoreText.anchor.set(1, 0.5); silverScoreText.x = silver.x - 90; // Position text to the left of the silver silverScoreText.y = silver.y; self.addChild(silverScoreText); var stone = self.attachAsset('stone', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2510 // Position stone below the wood }); self.addChild(stone); var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); stoneScoreText.anchor.set(1, 0.5); stoneScoreText.x = stone.x - 90; // Position text to the left of the stone stoneScoreText.y = stone.y; self.addChild(stoneScoreText); var gold = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2660 // Position gold below the stone }); self.addChild(gold); var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); goldScoreText.anchor.set(1, 0.5); goldScoreText.x = gold.x - 90; // Position text to the left of the gold goldScoreText.y = gold.y; self.addChild(goldScoreText); var bronze = self.attachAsset('bronze', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2510 // Position bronze above the stone }); self.addChild(bronze); var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); bronzeScoreText.anchor.set(1, 0.5); bronzeScoreText.x = bronze.x - 90; // Position text to the left of the bronze bronzeScoreText.y = bronze.y; self.addChild(bronzeScoreText); var crystal = self.attachAsset('crystal', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2660 // Position crystal below the bronze }); self.addChild(crystal); var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); crystalScoreText.anchor.set(1, 0.5); crystalScoreText.x = crystal.x - 90; // Position text to the left of the crystal crystalScoreText.y = crystal.y; self.addChild(crystalScoreText); var wall1 = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 1.0, x: 1024, // Center horizontally y: 2732 // Position at the bottom }); wall1.visible = true; self.addChild(wall1); // Add resources and score similar to Page1 var wood = self.attachAsset('wood', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2510 // Position wood below the trees }); self.addChild(wood); var statueText = new Text2('0', { size: 70, fill: 0x471e00 }); statueText.anchor.set(1, 0.5); statueText.x = 1800; // Position statueText on the screen statueText.y = 2510; // Align vertically with the wood asset self.addChild(statueText); var silver = self.attachAsset('silver', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2660 // Position silver directly below the wood }); self.addChild(silver); var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); silverScoreText.anchor.set(1, 0.5); silverScoreText.x = silver.x - 90; // Position text to the left of the silver silverScoreText.y = silver.y; self.addChild(silverScoreText); var stone = self.attachAsset('stone', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2510 // Position stone below the wood }); self.addChild(stone); var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); stoneScoreText.anchor.set(1, 0.5); stoneScoreText.x = stone.x - 90; // Position text to the left of the stone stoneScoreText.y = stone.y; self.addChild(stoneScoreText); var gold = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2660 // Position gold below the stone }); self.addChild(gold); var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); goldScoreText.anchor.set(1, 0.5); goldScoreText.x = gold.x - 90; // Position text to the left of the gold goldScoreText.y = gold.y; self.addChild(goldScoreText); var bronze = self.attachAsset('bronze', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2510 // Position bronze above the stone }); self.addChild(bronze); var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); bronzeScoreText.anchor.set(1, 0.5); bronzeScoreText.x = bronze.x - 90; // Position text to the left of the bronze bronzeScoreText.y = bronze.y; self.addChild(bronzeScoreText); var crystal = self.attachAsset('crystal', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2660 // Position crystal below the bronze }); self.addChild(crystal); var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); crystalScoreText.anchor.set(1, 0.5); crystalScoreText.x = crystal.x - 90; // Position text to the left of the crystal crystalScoreText.y = crystal.y; self.addChild(crystalScoreText); // Add map asset to Page4 below the pause button var background4 = self.attachAsset('background4', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0, scaleX: 2050 / 2048, // Match width of background1 scaleY: 2420 / 2732 // Match height of background1 }); // Add map asset to Page4 below the pause button var map = self.attachAsset('Map', { anchorX: 0.5, anchorY: 0.5, x: 100, y: 300 }); self.addChild(map); var mapText = new Text2('MAP', { size: 90, fill: 0xFFA500 // Orange color }); mapText.anchor.set(0.5, 0); mapText.x = map.x; mapText.y = map.y + map.height / 2 + 2; // Position directly below and closer to the map asset self.addChild(mapText); var build = self.attachAsset('Build', { anchorX: 0.5, anchorY: 0.5, x: map.x, y: mapText.y + mapText.height / 2 + 150 // Move 150 units further down below the MAP text }); self.addChild(build); var buildText = new Text2('BUILD', { size: 80, fill: 0xFFA500 // Orange color }); buildText.anchor.set(0.5, 0); buildText.x = build.x; buildText.y = build.y + build.height / 2 + 2; // Position directly below and closer to the build asset self.addChild(buildText); map.down = function (x, y, obj) { // Navigate to Page0 game.removeChild(page); page = game.addChild(new Page0()); }; // Add click event to build to navigate to Page7 build.down = function (x, y, obj) { // Navigate to Page7 game.removeChild(page); page = game.addChild(new Page7()); }; }); // Create a Page5 class by using the LK expand method to extend Container. var Page5 = Container.expand(function () { var self = Container.call(this); var wall1 = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 1.0, x: 1024, // Center horizontally y: 2732 // Position at the bottom }); self.addChild(wall1); // Add map asset to Page5 below the pause button var background5 = self.attachAsset('background5', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0, scaleX: 2050 / 2048, // Match width of background1 scaleY: 2420 / 2732 // Match height of background1 }); // Add map asset to Page5 below the pause button var map = self.attachAsset('Map', { anchorX: 0.5, anchorY: 0.5, x: 100, y: 300 }); self.addChild(map); var mapText = new Text2('MAP', { size: 90, fill: 0xFFA500 // Orange color }); mapText.anchor.set(0.5, 0); mapText.x = map.x; mapText.y = map.y + map.height / 2 + 2; // Position directly below and closer to the map asset self.addChild(mapText); var build = self.attachAsset('Build', { anchorX: 0.5, anchorY: 0.5, x: map.x, y: mapText.y + mapText.height / 2 + 150 // Move 150 units further down below the MAP text }); self.addChild(build); var buildText = new Text2('BUILD', { size: 80, fill: 0xFFA500 // Orange color }); buildText.anchor.set(0.5, 0); buildText.x = build.x; buildText.y = build.y + build.height / 2 + 2; // Position directly below and closer to the build asset self.addChild(buildText); map.down = function (x, y, obj) { // Navigate to Page0 game.removeChild(page); page = game.addChild(new Page0()); }; // Add click event to build to navigate to Page7 build.down = function (x, y, obj) { // Navigate to Page7 game.removeChild(page); page = game.addChild(new Page7()); }; // Add resources and score similar to Page1 var wood = self.attachAsset('wood', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2510 }); self.addChild(wood); var woodScoreText = new Text2('0', { size: 70, fill: 0x471e00 }); woodScoreText.anchor.set(1, 0.5); woodScoreText.x = 1800; woodScoreText.y = 2510; self.addChild(woodScoreText); var silver = self.attachAsset('silver', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2660 }); self.addChild(silver); var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); silverScoreText.anchor.set(1, 0.5); silverScoreText.x = silver.x - 90; silverScoreText.y = silver.y; self.addChild(silverScoreText); var stone = self.attachAsset('stone', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2510 }); self.addChild(stone); var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); stoneScoreText.anchor.set(1, 0.5); stoneScoreText.x = stone.x - 90; stoneScoreText.y = stone.y; self.addChild(stoneScoreText); var gold = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2660 }); gold.clickCount = 0; // Initialize gold score independently for Page5 self.addChild(gold); var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); goldScoreText.anchor.set(1, 0.5); goldScoreText.x = gold.x - 90; goldScoreText.y = gold.y; self.addChild(goldScoreText); var bronze = self.attachAsset('bronze', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2510 }); self.addChild(bronze); var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); bronzeScoreText.anchor.set(1, 0.5); bronzeScoreText.x = bronze.x - 90; bronzeScoreText.y = bronze.y; self.addChild(bronzeScoreText); var crystal = self.attachAsset('crystal', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2660 }); self.addChild(crystal); var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); crystalScoreText.anchor.set(1, 0.5); crystalScoreText.x = crystal.x - 90; crystalScoreText.y = crystal.y; self.addChild(crystalScoreText); }); var Page6 = Container.expand(function () { var self = Container.call(this); var wall1 = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 1.0, x: 1024, // Center horizontally y: 2732 // Position at the bottom }); self.addChild(wall1); // Add map asset to Page6 below the pause button var background6 = self.attachAsset('background6', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0, scaleX: 2050 / 2048, // Match width of background1 scaleY: 2420 / 2732 // Match height of background1 }); // Add map asset to Page6 below the pause button var map = self.attachAsset('Map', { anchorX: 0.5, anchorY: 0.5, x: 100, y: 300 }); self.addChild(map); var mapText = new Text2('MAP', { size: 90, fill: 0xFFA500 // Orange color }); mapText.anchor.set(0.5, 0); mapText.x = map.x; mapText.y = map.y + map.height / 2 + 2; // Position directly below and closer to the map asset self.addChild(mapText); var build = self.attachAsset('Build', { anchorX: 0.5, anchorY: 0.5, x: map.x, y: mapText.y + mapText.height / 2 + 150 // Move 150 units further down below the MAP text }); self.addChild(build); var buildText = new Text2('BUILD', { size: 80, fill: 0xFFA500 // Orange color }); buildText.anchor.set(0.5, 0); buildText.x = build.x; buildText.y = build.y + build.height / 2 + 2; // Position directly below and closer to the build asset self.addChild(buildText); // Add resources and score similar to Page1 var wood = self.attachAsset('wood', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2510 }); self.addChild(wood); var woodScoreText = new Text2('0', { size: 70, fill: 0x471e00 }); woodScoreText.anchor.set(1, 0.5); woodScoreText.x = 1800; woodScoreText.y = 2510; self.addChild(woodScoreText); var silver = self.attachAsset('silver', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2660 }); self.addChild(silver); var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); silverScoreText.anchor.set(1, 0.5); silverScoreText.x = silver.x - 90; silverScoreText.y = silver.y; self.addChild(silverScoreText); var stone = self.attachAsset('stone', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2510 }); self.addChild(stone); var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); stoneScoreText.anchor.set(1, 0.5); stoneScoreText.x = stone.x - 90; stoneScoreText.y = stone.y; self.addChild(stoneScoreText); var gold = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2660 }); self.addChild(gold); var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); goldScoreText.anchor.set(1, 0.5); goldScoreText.x = gold.x - 90; goldScoreText.y = gold.y; self.addChild(goldScoreText); var bronze = self.attachAsset('bronze', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2510 }); self.addChild(bronze); var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); bronzeScoreText.anchor.set(1, 0.5); bronzeScoreText.x = bronze.x - 90; bronzeScoreText.y = bronze.y; self.addChild(bronzeScoreText); var crystal = self.attachAsset('crystal', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2660 }); crystal.clickCount = 0; // Initialize crystal score independently for Page6 self.addChild(crystal); var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); crystalScoreText.anchor.set(1, 0.5); crystalScoreText.x = crystal.x - 90; crystalScoreText.y = crystal.y; self.addChild(crystalScoreText); map.down = function (x, y, obj) { // Navigate to Page0 game.removeChild(page); page = game.addChild(new Page0()); }; // Add click event to build to navigate to Page7 build.down = function (x, y, obj) { // Navigate to Page7 game.removeChild(page); page = game.addChild(new Page7()); }; }); var Page7 = Container.expand(function () { var self = Container.call(this); // Add map asset to Page7 below the pause button var background7 = self.attachAsset('background7', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0, scaleX: 2050 / 2048, // Match width of background1 scaleY: 2420 / 2732 // Match height of background1 }); // Add drag functionality to the background7 image self.lastX = background7.x; self.lastY = background7.y; self.down = function (x, y, obj) { self.dragging = true; self.data = obj.data; self.initialClick = { x: x, y: y }; self.offset = { x: background7.x - x, y: background7.y - y }; }; self.up = function () { self.dragging = false; self.data = null; }; self.move = function (x, y, obj) { if (self.dragging) { var dx = x - self.initialClick.x; var dy = y - self.initialClick.y; background7.x = x + self.offset.x; background7.y = y + self.offset.y; self.initialClick = { x: x, y: y }; self.lastX = background7.x; self.lastY = background7.y; } }; var wall1 = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 1.0, x: 1024, // Center horizontally y: 2732 // Position at the bottom }); self.addChild(wall1); // Add map asset to Page7 below the pause button var map = self.attachAsset('Map', { anchorX: 0.5, anchorY: 0.5, x: 100, y: 300 }); self.addChild(map); var mapText = new Text2('MAP', { size: 90, fill: 0xFFA500 // Orange color }); mapText.anchor.set(0.5, 0); mapText.x = map.x; mapText.y = map.y + map.height / 2 + 2; // Position directly below and closer to the map asset self.addChild(mapText); // Add resources and score similar to Page1 var wood = self.attachAsset('wood', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2510 }); self.addChild(wood); var woodScoreText = new Text2('0', { size: 70, fill: 0x471e00 }); woodScoreText.anchor.set(1, 0.5); woodScoreText.x = 1800; woodScoreText.y = 2510; self.addChild(woodScoreText); var silver = self.attachAsset('silver', { anchorX: 0.5, anchorY: 0.5, x: 1902, y: 2660 }); self.addChild(silver); var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); silverScoreText.anchor.set(1, 0.5); silverScoreText.x = silver.x - 90; silverScoreText.y = silver.y; self.addChild(silverScoreText); var stone = self.attachAsset('stone', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2510 }); self.addChild(stone); var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); stoneScoreText.anchor.set(1, 0.5); stoneScoreText.x = stone.x - 90; stoneScoreText.y = stone.y; self.addChild(stoneScoreText); var gold = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5, x: 1220, y: 2660 }); self.addChild(gold); var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); goldScoreText.anchor.set(1, 0.5); goldScoreText.x = gold.x - 90; goldScoreText.y = gold.y; self.addChild(goldScoreText); var bronze = self.attachAsset('bronze', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2510 }); self.addChild(bronze); var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); bronzeScoreText.anchor.set(1, 0.5); bronzeScoreText.x = bronze.x - 90; bronzeScoreText.y = bronze.y; self.addChild(bronzeScoreText); var crystal = self.attachAsset('crystal', { anchorX: 0.5, anchorY: 0.5, x: 595, y: 2660 }); self.addChild(crystal); var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); crystalScoreText.anchor.set(1, 0.5); crystalScoreText.x = crystal.x - 90; crystalScoreText.y = crystal.y; self.addChild(crystalScoreText); map.down = function (x, y, obj) { // Navigate to Page0 game.removeChild(page); page = game.addChild(new Page0()); }; }); var Tree = Container.expand(function (assetId, x, y) { var self = Container.call(this); var tree = self.attachAsset(assetId, { anchorX: -1.1, anchorY: 3, x: x, y: y }); tree.clickCount = 0; self.addChild(tree); self.getClickCount = function () { return tree.clickCount; }; self.incrementClickCount = function () { tree.clickCount += 1; }; self.hide = function () { tree.visible = false; }; return self; }); var WoodScoreText = Container.expand(function () { var self = Container.call(this); var woodScoreText = new Text2('0', { size: 70, fill: 0x471e00 }); woodScoreText.anchor.set(1, 0.5); self.addChild(woodScoreText); self.setText = function (text) { woodScoreText.setText(text); }; self.getText = function () { return woodScoreText.text; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var lastScores = storage.lastScores || {}; var lastSilverScore = lastScores.silver || 0; var lastStoneScore = lastScores.stone || 0; var lastGoldScore = lastScores.gold || 0; var lastBronzeScore = lastScores.bronze || 0; var lastCrystalScore = lastScores.crystal || 0; var lastWoodScore = lastScores.wood || 0; // Update score texts on all pages function updateScoreTexts() { var woodScoreText = new Text2('0', { size: 70, fill: 0x471e00 }); // Define woodScoreText in the global scope woodScoreText.anchor.set(1, 0.5); woodScoreText.setText(lastWoodScore); // Set woodScoreText to last known score woodScoreText.x = 1800; // Position woodScoreText on the screen woodScoreText.y = 2510; // Align vertically with the wood asset game.addChild(woodScoreText); // Add woodScoreText to the display list silverScoreText.setText(lastSilverScore); stoneScoreText.setText(lastStoneScore); goldScoreText.setText(lastGoldScore); bronzeScoreText.setText(lastBronzeScore); crystalScoreText.setText(lastCrystalScore); } updateScoreTexts(); function _slicedToArray2(r, e) { return _arrayWithHoles2(r) || _iterableToArrayLimit2(r, e) || _unsupportedIterableToArray2(r, e) || _nonIterableRest2(); } function _nonIterableRest2() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray2(r, a) { if (r) { if ("string" == typeof r) { return _arrayLikeToArray2(r, a); } var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray2(r, a) : void 0; } } function _arrayLikeToArray2(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; } function _iterableToArrayLimit2(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) { return; } f = !1; } else { for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) { return; } } finally { if (o) { throw n; } } } return a; } } function _arrayWithHoles2(r) { if (Array.isArray(r)) { return r; } } function saveStoneCooldowns() { var stoneCooldowns = []; for (var i = 1; i <= 10; i++) { var stone = window["stone" + i]; if (stone && stone.timetext && stone.timetext.visible) { stoneCooldowns.push({ id: i, cooldown: stone.timetext.getText() }); } } if (typeof localStorage !== 'undefined') { localStorage.setItem('stoneCooldowns', JSON.stringify(stoneCooldowns)); } } function restoreStoneCooldowns() { var storedStoneCooldowns = typeof localStorage !== 'undefined' ? localStorage.getItem('stoneCooldowns') : null; var stoneCooldowns = storedStoneCooldowns ? JSON.parse(storedStoneCooldowns) : []; stoneCooldowns.forEach(function (stoneData) { var stone = window["stone" + stoneData.id]; var _stoneData$cooldown$s = stoneData.cooldown.split(':').map(Number), _stoneData$cooldown$s2 = _slicedToArray2(_stoneData$cooldown$s, 2), minutes = _stoneData$cooldown$s2[0], seconds = _stoneData$cooldown$s2[1]; var totalSeconds = minutes * 60 + seconds; stone.clickCount = 3; stone.visible = false; stone.timetext.visible = true; stone.timetext.setText(stoneData.cooldown); var cooldown = totalSeconds; var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; stone.timetext.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); stone.clickCount = 0; stone.visible = true; stone.timetext.visible = false; } }, 1000); }); } function handleTreeClick(tree) { if (tree.clickCount < 3) { tree.clickCount++; if (tree.clickCount === 3) { tree.visible = false; // Use the visible property to hide the tree tree.timetext.visible = true; // Show timetext when tree is hidden var cooldown = 180; // 3 minutes in seconds var _interval = function interval() { if (cooldown > 0) { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; tree.timetext.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); LK.setTimeout(_interval, 1000); } else { tree.clickCount = 0; // Reset click count after 3 minutes tree.visible = true; // Make the tree visible again tree.timetext.visible = false; // Hide timetext when tree becomes visible } }; LK.setTimeout(_interval, 1000); } updateLastScores(); // Update last known scores for all resources var currentPage = page.constructor.name; if (!pageScores[currentPage]) { pageScores[currentPage] = { wood: { clickCount: 0 }, silver: { clickCount: 0 }, stone: { clickCount: 0 }, gold: { clickCount: 0 }, bronze: { clickCount: 0 }, crystal: { clickCount: 0 } }; } pageScores[currentPage].wood.clickCount = wood.clickCount; // Update score text for each resource woodScoreText.setText(pageScores[currentPage].wood.clickCount); silverScoreText.setText(pageScores[currentPage].silver.clickCount); stoneScoreText.setText(pageScores[currentPage].stone.clickCount); goldScoreText.setText(pageScores[currentPage].gold.clickCount); bronzeScoreText.setText(pageScores[currentPage].bronze.clickCount); crystalScoreText.setText(pageScores[currentPage].crystal.clickCount); // Log the click count for the tree console.log("Tree clicked ".concat(tree.clickCount, " times.")); } } var wood = { clickCount: 0 }; // Define wood object for global use var pageScores = { Page1: { wood: { clickCount: 0 } }, Page2: { stone: { clickCount: 0 } }, Page3: { bronze: { clickCount: 0 } }, Page4: { silver: { clickCount: 0 } }, Page5: { gold: { clickCount: 0 } }, Page6: { crystal: { clickCount: 0 } } }; // Initialize pageScores for each page var woodScoreText = new WoodScoreText(); // Define woodScoreText in the global scope woodScoreText.setText(lastWoodScore); // Set woodScoreText to last known score woodScoreText.x = 1800; // Position woodScoreText on the screen woodScoreText.y = 2510; // Align vertically with the wood asset game.addChild(woodScoreText); // Add woodScoreText to the display list woodScoreText.setText(lastWoodScore); // Set woodScoreText to last known score woodScoreText.x = 1800; // Position woodScoreText on the screen woodScoreText.y = 2510; // Align vertically with the wood asset game.addChild(woodScoreText); // Add woodScoreText to the display list var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); // Define silverScoreText in the global scope silverScoreText.anchor.set(1, 0.5); silverScoreText.x = 1712; // Position silverScoreText on the screen silverScoreText.y = 2660; // Align vertically with the silver asset game.addChild(silverScoreText); // Add silverScoreText to the display list silverScoreText.setText(lastSilverScore); // Set silverScoreText to last known score var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); // Define stoneScoreText in the global scope stoneScoreText.anchor.set(1, 0.5); stoneScoreText.setText(lastStoneScore); // Set stoneScoreText to last known score var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); // Define goldScoreText in the global scope goldScoreText.anchor.set(1, 0.5); goldScoreText.setText(lastGoldScore); // Set goldScoreText to last known score var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); // Define bronzeScoreText in the global scope bronzeScoreText.anchor.set(1, 0.5); bronzeScoreText.setText(lastBronzeScore); // Set bronzeScoreText to last known score var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); // Define crystalScoreText in the global scope crystalScoreText.anchor.set(1, 0.5); crystalScoreText.setText(lastCrystalScore); // Set crystalScoreText to last known score // Initialize storage time if not already set if (!storage.time) { storage.time = new Date().getTime(); } // Calculate time elapsed since last visit var currentTime = new Date().getTime(); var timeElapsed = currentTime - storage.time; console.log('Time Elapsed:', timeElapsed); // Update storage time to current time storage.time = currentTime; // Function to update tree cooldowns based on time elapsed function updateTreeCooldowns(timeElapsed) { var secondsElapsed = Math.floor(timeElapsed / 1000); for (var i = 1; i <= 16; i++) { var tree = window["tree" + i]; if (tree && tree.timetext && tree.timetext.visible) { var _tree$timetext$getTe = tree.timetext.getText().split(':').map(Number), _tree$timetext$getTe2 = _slicedToArray(_tree$timetext$getTe, 2), minutes = _tree$timetext$getTe2[0], seconds = _tree$timetext$getTe2[1]; var totalSeconds = minutes * 60 + seconds; totalSeconds = Math.max(0, totalSeconds - secondsElapsed); minutes = Math.floor(totalSeconds / 60); seconds = totalSeconds % 60; tree.timetext.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (totalSeconds <= 0) { tree.clickCount = 0; tree.visible = true; tree.timetext.visible = false; } } } } // Update tree cooldowns based on time elapsed updateTreeCooldowns(timeElapsed); function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) { return _arrayLikeToArray(r, a); } var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) { return; } f = !1; } else { for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) { return; } } finally { if (o) { throw n; } } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) { return r; } } var pageScores = { Page1: { wood: { clickCount: 0 }, silver: { clickCount: 0 }, stone: { clickCount: 0 }, gold: { clickCount: 0 }, bronze: { clickCount: 0 }, crystal: { clickCount: 0 } }, Page2: { wood: { clickCount: 0 }, silver: { clickCount: 0 }, stone: { clickCount: 0 }, gold: { clickCount: 0 }, bronze: { clickCount: 0 }, crystal: { clickCount: 0 } }, Page3: { wood: { clickCount: 0 }, silver: { clickCount: 0 }, stone: { clickCount: 0 }, gold: { clickCount: 0 }, bronze: { clickCount: 0 }, crystal: { clickCount: 0 } }, Page4: { wood: { clickCount: 0 }, silver: { clickCount: 0 }, stone: { clickCount: 0 }, gold: { clickCount: 0 }, bronze: { clickCount: 0 }, crystal: { clickCount: 0 } }, Page5: { wood: { clickCount: 0 }, silver: { clickCount: 0 }, stone: { clickCount: 0 }, gold: { clickCount: 0 }, bronze: { clickCount: 0 }, crystal: { clickCount: 0 } }, Page6: { wood: { clickCount: 0 }, silver: { clickCount: 0 }, stone: { clickCount: 0 }, gold: { clickCount: 0 }, bronze: { clickCount: 0 }, crystal: { clickCount: 0 } } }; var stoneScoreText = new Text2('0', { size: 70, fill: 0x00ff00 }); stoneScoreText.anchor.set(1, 0.5); var lastWoodScore = 0; // Initialize lastWoodScore to store the last known wood score var silver = { clickCount: 0 }; // Define silver object var silverScoreText = new Text2('0', { size: 70, fill: 0xc0c0c0 }); // Define silverScoreText in the global scope var lastSilverScore = 0; // Initialize lastSilverScore to store the last known silver score var stone = { clickCount: 0 }; // Define stone object var lastStoneScore = 0; // Initialize lastStoneScore to store the last known stone score var gold = { clickCount: 0 }; // Define gold object var goldScoreText = new Text2('0', { size: 70, fill: 0xffd700 }); // Define goldScoreText in the global scope var lastGoldScore = 0; // Initialize lastGoldScore to store the last known gold score var bronze = { clickCount: 0 }; // Define bronze object var bronzeScoreText = new Text2('0', { size: 70, fill: 0xcd7f32 }); // Define bronzeScoreText in the global scope var lastBronzeScore = 0; // Initialize lastBronzeScore to store the last known bronze score var crystal = { clickCount: 0 }; // Define crystal object var crystalScoreText = new Text2('0', { size: 70, fill: 0x00ffff }); // Define crystalScoreText in the global scope var lastCrystalScore = 0; // Initialize lastCrystalScore to store the last known crystal score // Function to update last known scores function updateLastScores() { lastSilverScore = silver.clickCount; lastStoneScore = stone.clickCount; lastGoldScore = gold.clickCount; lastBronzeScore = bronze.clickCount; lastCrystalScore = crystal.clickCount; lastWoodScore = wood.clickCount; // Update woodScore } var page = game.addChild(new Page0()); //{0.b} // Define tree variables to fix 'not defined' error for (var i = 1; i <= 16; i++) { window["tree" + i] = { timetext: new Text2('3:00', { size: 80, fill: 0x8B4513 }), clickCount: 0, visible: true }; window["tree" + i].timetext.anchor.set(0.5, 0.5); window["tree" + i].timetext.visible = false; // Initially hidden } LK.setTimeout(function () { // Function to save tree cooldowns to local storage function saveTreeCooldowns() { var treeCooldowns = []; for (var i = 1; i <= 16; i++) { var tree = window["tree" + i]; if (tree.timetext.visible) { treeCooldowns.push({ id: i, cooldown: tree.timetext.getText() }); } } localStorage.setItem('treeCooldowns', JSON.stringify(treeCooldowns)); } // Function to restore tree cooldowns from local storage function restoreTreeCooldowns() { var storedTreeCooldowns = typeof localStorage !== 'undefined' ? localStorage.getItem('treeCooldowns') : null; var treeCooldowns = storedTreeCooldowns ? JSON.parse(storedTreeCooldowns) : []; treeCooldowns.forEach(function (treeData) { var tree = window["tree" + treeData.id]; var _treeData$cooldown$sp = treeData.cooldown.split(':').map(Number), _treeData$cooldown$sp2 = _slicedToArray(_treeData$cooldown$sp, 2), minutes = _treeData$cooldown$sp2[0], seconds = _treeData$cooldown$sp2[1]; var totalSeconds = minutes * 60 + seconds; tree.clickCount = 3; tree.visible = false; tree.timetext.visible = true; tree.timetext.setText(treeData.cooldown); var cooldown = totalSeconds; var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; tree.timetext.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); tree.clickCount = 0; tree.visible = true; tree.timetext.visible = false; } }, 1000); }); } // Call restoreTreeCooldowns when the game starts function restoreTreeCooldowns() { var storedTreeCooldowns = typeof localStorage !== 'undefined' ? localStorage.getItem('treeCooldowns') : null; var treeCooldowns = storedTreeCooldowns ? JSON.parse(storedTreeCooldowns) : []; treeCooldowns.forEach(function (treeData) { var tree = window["tree" + treeData.id]; var _treeData$cooldown$sp = treeData.cooldown.split(':').map(Number), _treeData$cooldown$sp2 = _slicedToArray(_treeData$cooldown$sp, 2), minutes = _treeData$cooldown$sp2[0], seconds = _treeData$cooldown$sp2[1]; var totalSeconds = minutes * 60 + seconds; tree.clickCount = 3; tree.visible = false; tree.timetext.visible = true; tree.timetext.setText(treeData.cooldown); var cooldown = totalSeconds; var interval = LK.setInterval(function () { cooldown--; var minutes = Math.floor(cooldown / 60); var seconds = cooldown % 60; tree.timetext.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); if (cooldown <= 0) { LK.clearInterval(interval); tree.clickCount = 0; tree.visible = true; tree.timetext.visible = false; } }, 1000); }); } restoreTreeCooldowns(); // Restore tree cooldowns from persisted data woodScoreText.setText(wood.clickCount); // Set woodScoreText to restored value var lastScores = storage.lastScores || {}; lastStatueScore = lastScores.statue || 0; lastSilverScore = lastScores.silver || 0; lastStoneScore = lastScores.stone || 0; lastGoldScore = lastScores.gold || 0; lastBronzeScore = lastScores.bronze || 0; lastCrystalScore = lastScores.crystal || 0; silverScoreText.setText(lastSilverScore); stoneScoreText.setText(lastStoneScore); goldScoreText.setText(lastGoldScore); bronzeScoreText.setText(lastBronzeScore); crystalScoreText.setText(lastCrystalScore); woodScoreText.setText(lastWoodScore); // Save tree cooldowns before navigating away from the page LK.on('beforeunload', function () { saveTreeCooldowns(); storage.woodClickCount = wood.clickCount; storage.lastScores = { silver: lastSilverScore, stone: lastStoneScore, gold: lastGoldScore, bronze: lastBronzeScore, crystal: lastCrystalScore, wood: lastWoodScore }; // Update scores in storage on page navigation function saveScoresToStorage() { storage.lastScores = { silver: silver.clickCount, stone: stone.clickCount, gold: gold.clickCount, bronze: bronze.clickCount, crystal: crystal.clickCount, wood: wood.clickCount }; } }); //{0.b}; }, 30000); // 30 seconds delay ; //{0.b}; ; //{0.b}
===================================================================
--- original.js
+++ change.js
@@ -2604,8 +2604,9 @@
silverScoreText.anchor.set(1, 0.5);
silverScoreText.x = 1712; // Position silverScoreText on the screen
silverScoreText.y = 2660; // Align vertically with the silver asset
game.addChild(silverScoreText); // Add silverScoreText to the display list
+silverScoreText.setText(lastSilverScore); // Set silverScoreText to last known score
var stoneScoreText = new Text2('0', {
size: 70,
fill: 0x00ff00
}); // Define stoneScoreText in the global scope
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"!