User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'down')' in or related to this line: 'tree6.down = function (x, y, obj) {' Line Number: 391
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'down')' in or related to this line: 'tree5_below.down = function (x, y, obj) {' Line Number: 375
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'down')' in or related to this line: 'tree1_below.down = function (x, y, obj) {' Line Number: 359
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'down')' in or related to this line: 'tree5.down = function (x, y, obj) {' Line Number: 343
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'down')' in or related to this line: 'tree4.down = function (x, y, obj) {' Line Number: 327
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'down')' in or related to this line: 'tree7_below.down = function (x, y, obj) {' Line Number: 311
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'down')' in or related to this line: 'tree3_below.down = function (x, y, obj) {' Line Number: 295
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'down')' in or related to this line: 'tree7.down = function (x, y, obj) {' Line Number: 279
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'down')' in or related to this line: 'tree3.down = function (x, y, obj) {' Line Number: 264
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'down')' in or related to this line: 'tree2.down = function (x, y, obj) {' Line Number: 248
User prompt
Add function of count clicks to all trees in page1 it i click on any tree increase the text1 by 5.
User prompt
Make the text1 that is beside wood asset is the score for wood resources
User prompt
Add statue object to page1 can count clicks and add score to wood score.
User prompt
Make woodstatue object as statue that count clicks
User prompt
Make the woodstatue as button if i click it add 5 to text1
User prompt
If i click on woodstatue in page1 increase text1 by 5 change the score from '0' to '5' by each click.
User prompt
Make the woodstatue object in page1 can count clicks and increase wood score by 5 for each click.
User prompt
Add statue to page1 to count clicks.
User prompt
Make the text1 of wood increased by 5 for each click on any tree in page1.
User prompt
Make each click on the trees give 5 wood & increase the wood score by 5.
User prompt
Add text2 for stone, text3 for bronze, text4 for silver, text5 for gold, text6 for crystal make the text close to assets as the text1 of wood.
Code edit (1 edits merged)
Please save this source code
User prompt
Add text1 for wood score, make its position beside wood asset from the left side in page1
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Page0 = Container.expand(function () { var self = Container.call(this); // Get and automatically addChild to self asset with id 'background0' with the anchor point set to 0, 0 var background0 = self.attachAsset('background0', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, scaleX: 1.5, scaleY: 1.5 }); 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 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"); } var dx = x - self.initialClick.x; var dy = y - self.initialClick.y; background0.x = x + self.offset.x; background0.y = y + self.offset.y; 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 game.removeChild(page); page = game.addChild(new Page1()); }; // 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 game.removeChild(page); page = game.addChild(new Page2()); }; // 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 game.removeChild(page); page = game.addChild(new Page3()); }; // 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 game.removeChild(page); page = game.addChild(new Page4()); }; // 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 game.removeChild(page); page = game.addChild(new Page5()); }; // 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 game.removeChild(page); page = game.addChild(new Page6()); }; }); // Create a Page1 class by using the LK expand method to extend Container. var Page1 = Container.expand(function () { var self = Container.call(this); // Get and automatically addChild to self asset with id 'background1' with the anchor point set to 0, 0 var background1 = self.attachAsset('background1', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); // Get and automatically addChild to self asset with id 'wall1' with the anchor point set to 0.5, 1.0 var wall1 = self.attachAsset('wall1', { anchorX: 0.5, anchorY: 1.0, x: 1024, // Center horizontally y: 2732 // Position at the bottom }); // Get and automatically addChild to self asset with id 'tree1' with the anchor point set to 0.5, 0.5 var tree1 = self.attachAsset('tree1', { anchorX: -1.1, anchorY: 3, x: 1000, // Center horizontally y: 1366 // Center vertically }); // Add click event to tree1 to animate woodstatue tree1.clickCount = 0; tree1.down = function (x, y, obj) { tree1.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree1.clickCount >= 3) { tree1.visible = false; } }; var tree2 = self.attachAsset('tree2', { anchorX: -1.1, anchorY: 3, x: 700, // Position tree2 to the left of tree1 y: 1366 // Align vertically with tree1 }); tree2.clickCount = 0; tree2.down = function (x, y, obj) { tree2.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree2.clickCount >= 3) { tree2.visible = false; } }; // Add woodstatue below tree2 var tree3 = self.attachAsset('tree3', { anchorX: -1.1, anchorY: 3, x: 380, // Position tree3 slightly more to the left of tree2 // Position tree3 to the left of tree2 y: 1366 // Align vertically with tree2 }); tree3.clickCount = 0; tree3.down = function (x, y, obj) { tree3.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree3.clickCount >= 3) { tree3.visible = false; } }; // Add woodstatue below tree3 var tree7 = self.attachAsset('tree7', { anchorX: -1.1, anchorY: 3, x: 380, // Align horizontally with tree3 y: 1666 // Position tree7 below tree3 }); tree7.clickCount = 0; tree7.down = function (x, y, obj) { tree7.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree7.clickCount >= 3) { tree7.visible = false; } }; // Add woodstatue below tree7 var tree3_below = self.attachAsset('tree3', { anchorX: -1.1, anchorY: 3, x: 380, // Align horizontally with tree7 y: 1966 // Position tree3 below tree7 }); tree3_below.clickCount = 0; tree3_below.down = function (x, y, obj) { tree3_below.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree3_below.clickCount >= 3) { tree3_below.visible = false; } }; // Get and automatically addChild to self asset with id 'tree7' with the anchor point set to 0.5, 0.5 var tree7_below = self.attachAsset('tree7', { anchorX: -1.1, anchorY: 3, x: 380, // Align horizontally with tree3_below y: 2266 // Position tree7 below tree3_below }); tree7_below.clickCount = 0; tree7_below.down = function (x, y, obj) { tree7_below.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree7_below.clickCount >= 3) { tree7_below.visible = false; } }; // Get and automatically addChild to self asset with id 'tree4' with the anchor point set to 0.5, 0.5 var tree4 = self.attachAsset('tree4', { anchorX: -1.1, anchorY: 3, x: 100, // Position tree4 to the left of tree3 y: 1366 // Align vertically with tree3 }); tree4.clickCount = 0; tree4.down = function (x, y, obj) { tree4.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree4.clickCount >= 3) { tree4.visible = false; } }; // Add woodstatue below tree4 var tree5 = self.attachAsset('tree5', { anchorX: -1.1, anchorY: 3, x: 1000, // Align horizontally with tree1 y: 1666 // Position tree5 below tree1 }); tree5.clickCount = 0; tree5.down = function (x, y, obj) { tree5.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree5.clickCount >= 3) { tree5.visible = false; } }; // Add woodstatue below tree5 var tree1_below = self.attachAsset('tree1', { anchorX: -1.1, anchorY: 3, x: 1000, // Align horizontally with tree5 y: 1966 // Position tree1 below tree5 }); tree1_below.clickCount = 0; tree1_below.down = function (x, y, obj) { tree1_below.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree1_below.clickCount >= 3) { tree1_below.visible = false; } }; // Get and automatically addChild to self asset with id 'tree5' with the anchor point set to 0.5, 0.5 var tree5_below = self.attachAsset('tree5', { anchorX: -1.1, anchorY: 3, x: 1000, // Align horizontally with tree1_below y: 2266 // Position tree5 below tree1_below }); tree5_below.clickCount = 0; tree5_below.down = function (x, y, obj) { tree5_below.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree5_below.clickCount >= 3) { tree5_below.visible = false; } }; // Get and automatically addChild to self asset with id 'tree6' with the anchor point set to 0.5, 0.5 var tree6 = self.attachAsset('tree6', { anchorX: -1.1, anchorY: 3, x: 700, // Position tree6 to the left of tree5 y: 1666 // Align vertically with tree5 }); tree6.clickCount = 0; tree6.down = function (x, y, obj) { tree6.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree6.clickCount >= 3) { tree6.visible = false; } }; // Add woodstatue below tree6 var tree2_below = self.attachAsset('tree2', { anchorX: -1.1, anchorY: 3, x: 700, // Align horizontally with tree6 y: 1966 // Position tree2 below tree6 }); tree2_below.clickCount = 0; tree2_below.down = function (x, y, obj) { tree2_below.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree2_below.clickCount >= 3) { tree2_below.visible = false; } }; // Get and automatically addChild to self asset with id 'tree6' with the anchor point set to 0.5, 0.5 var tree6_below = self.attachAsset('tree6', { anchorX: -1.1, anchorY: 3, x: 700, // Align horizontally with tree2_below y: 2266 // Position tree6 below tree2_below }); tree6_below.clickCount = 0; tree6_below.down = function (x, y, obj) { tree6_below.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree6_below.clickCount >= 3) { tree6_below.visible = false; } }; // Get and automatically addChild to self asset with id 'tree8' with the anchor point set to 0.5, 0.5 var tree8 = self.attachAsset('tree8', { anchorX: -1.1, anchorY: 3, x: 80, // Position tree8 to the left of tree7 y: 1666 // Align vertically with tree7 }); tree8.clickCount = 0; tree8.down = function (x, y, obj) { tree8.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree8.clickCount >= 3) { tree8.visible = false; } }; // Add woodstatue below tree8 // Get and automatically addChild to self asset with id 'tree4' with the anchor point set to 0.5, 0.5 var tree4_below = self.attachAsset('tree4', { anchorX: -1.1, anchorY: 3, x: 80, // Align horizontally with tree8 y: 1966 // Position tree4 below tree8 }); tree4_below.clickCount = 0; tree4_below.down = function (x, y, obj) { tree4_below.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree4_below.clickCount >= 3) { tree4_below.visible = false; } }; // Get and automatically addChild to self asset with id 'tree8' with the anchor point set to 0.5, 0.5 var tree8_below = self.attachAsset('tree8', { anchorX: -1.1, anchorY: 3, x: 80, // Align horizontally with tree4_below y: 2266 // Position tree8 below tree4_below }); tree8_below.clickCount = 0; tree8_below.down = function (x, y, obj) { tree8_below.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree8_below.clickCount >= 3) { tree8_below.visible = false; } }; // Get and automatically addChild to self asset with id 'tree1' with the anchor point set to 0.5, 0.5 var tree1_below2 = self.attachAsset('tree1', { anchorX: -1.1, anchorY: 3, x: 1000, // Align horizontally with tree1_below y: 2566 // Position tree1_below2 below tree1_below }); tree1_below2.clickCount = 0; tree1_below2.down = function (x, y, obj) { tree1_below2.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree1_below2.clickCount >= 3) { tree1_below2.visible = false; } }; // Get and automatically addChild to self asset with id 'tree2' with the anchor point set to 0.5, 0.5 var tree2_below2 = self.attachAsset('tree2', { anchorX: -1.1, anchorY: 3, x: 700, // Align horizontally with tree2_below y: 2566 // Position tree2_below2 below tree2_below }); tree2_below2.clickCount = 0; tree2_below2.down = function (x, y, obj) { tree2_below2.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree2_below2.clickCount >= 3) { tree2_below2.visible = false; } }; // Get and automatically addChild to self asset with id 'tree3' with the anchor point set to 0.5, 0.5 var tree3_below2 = self.attachAsset('tree3', { anchorX: -1.1, anchorY: 3, x: 380, // Align horizontally with tree3_below y: 2566 // Position tree3_below2 below tree3_below }); tree3_below2.clickCount = 0; tree3_below2.down = function (x, y, obj) { tree3_below2.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree3_below2.clickCount >= 3) { tree3_below2.visible = false; } }; // Get and automatically addChild to self asset with id 'tree4' with the anchor point set to 0.5, 0.5 var tree4_below2 = self.attachAsset('tree4', { anchorX: -1.1, anchorY: 3, x: 80, // Align horizontally with tree4_below y: 2566 // Position tree4_below2 below tree4_below }); tree4_below2.clickCount = 0; tree4_below2.down = function (x, y, obj) { tree4_below2.clickCount++; var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); if (tree4_below2.clickCount >= 3) { tree4_below2.visible = false; } }; // Add wood asset to Page1 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 }); // Add statue to Page1 to count clicks var woodStatue = new WoodStatue(); woodStatue.x = 1500; woodStatue.y = 2510; self.addChild(woodStatue); // Add text1 for wood score beside wood asset var woodScoreText = new Text1(); woodScoreText.setText('0'); woodScoreText.x = wood.x - 90; // Position beside wood asset from the left woodScoreText.y = wood.y; self.addChild(woodScoreText); // Add silver asset below the wood 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 text4 for silver score beside silver asset var silverScoreText = new Text1(); silverScoreText.setText('0'); silverScoreText.x = silver.x - 90; // Position beside silver asset from the left silverScoreText.y = silver.y; self.addChild(silverScoreText); // Add stone asset to Page1 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 text2 for stone score beside stone asset var stoneScoreText = new Text1(); stoneScoreText.setText('0'); stoneScoreText.x = stone.x - 90; // Position beside stone asset from the left stoneScoreText.y = stone.y; self.addChild(stoneScoreText); // Add gold asset below the stone 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 text5 for gold score beside gold asset var goldScoreText = new Text1(); goldScoreText.setText('0'); goldScoreText.x = gold.x - 90; // Position beside gold asset from the left goldScoreText.y = gold.y; self.addChild(goldScoreText); // Add bronze asset to Page1 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 text3 for bronze score beside bronze asset var bronzeScoreText = new Text1(); bronzeScoreText.setText('0'); bronzeScoreText.x = bronze.x - 90; // Position beside bronze asset from the left bronzeScoreText.y = bronze.y; self.addChild(bronzeScoreText); // Add crystal asset below the bronze 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 text6 for crystal score beside crystal asset var crystalScoreText = new Text1(); crystalScoreText.setText('0'); crystalScoreText.x = crystal.x - 90; // Position beside crystal asset from the left crystalScoreText.y = crystal.y; self.addChild(crystalScoreText); }); var Page2 = Container.expand(function () { var self = Container.call(this); // Get and automatically addChild to self asset with id 'background2' with the anchor point set to 0, 0 var background2 = self.attachAsset('background2', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0 }); }); var Page3 = Container.expand(function () { var self = Container.call(this); // Get and automatically addChild to self asset with id 'background3' with the anchor point set to 0, 0 var background3 = self.attachAsset('background3', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0 }); }); var Page4 = Container.expand(function () { var self = Container.call(this); // Get and automatically addChild to self asset with id 'background4' with the anchor point set to 0, 0 var background4 = self.attachAsset('background4', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0 }); }); // Create a Page5 class by using the LK expand method to extend Container. var Page5 = Container.expand(function () { var self = Container.call(this); // Get and automatically addChild to self asset with id 'background5' with the anchor point set to 0, 0 var background5 = self.attachAsset('background5', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0 }); }); var Page6 = Container.expand(function () { var self = Container.call(this); // Get and automatically addChild to self asset with id 'background6' with the anchor point set to 0, 0 var background6 = self.attachAsset('background6', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0 }); }); var Statue = Container.expand(function () { var self = Container.call(this); // Attach the woodstatue asset to the Statue class var statueGraphics = self.attachAsset('woodstatue', { anchorX: 0.5, anchorY: 0.5 }); // Event handler for when the statue is clicked self.down = function (x, y, obj) { var currentStatueCount = parseInt(statueCountTxt.text); statueCountTxt.setText(currentStatueCount + 1); }; return self; }); var Text1 = Container.expand(function () { var self = Container.call(this); var text = new Text2('0', { size: 100, fill: 0xfd0000 }); text.anchor.set(0.5, 0.5); self.addChild(text); self.setText = function (newText) { text.setText(newText); }; return self; }); var WoodStatue = Container.expand(function () { var self = Container.call(this); var woodStatueGraphics = self.attachAsset('woodstatue', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { var currentScore = parseInt(woodScoreTxt.text); woodScoreTxt.setText(currentScore + 5); var currentStatueCount = parseInt(statueCountTxt.text); statueCountTxt.setText(currentStatueCount + 5); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Create and display the statue count text in the middle of the screen var statueCountTxt = new Text1(); statueCountTxt.setText('0'); statueCountTxt.x = 2048 / 2; // Center horizontally statueCountTxt.y = 200; // Position below the wood score LK.gui.top.addChild(statueCountTxt); // Add the statue count text to the GUI overlay // Create and display the score text for counting wood var woodScoreTxt = new Text1(); woodScoreTxt.setText('0'); woodScoreTxt.x = 2048 / 2; // Center horizontally woodScoreTxt.y = 100; // Position at the top of the screen LK.gui.top.addChild(woodScoreTxt); // Add the wood score text to the GUI overlay var page = game.addChild(new Page0()); //{0.b} ; //{0.b}
===================================================================
--- original.js
+++ change.js
@@ -523,20 +523,12 @@
// Position wood in the middle of the screen
y: 2510 // Position wood below the trees
});
// Add statue to Page1 to count clicks
- var statue = self.attachAsset('woodstatue', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 1500,
- // Position statue on the screen
- y: 2510 // Align vertically with wood
- });
- statue.down = function (x, y, obj) {
- var currentScore = parseInt(woodScoreTxt.text);
- woodScoreTxt.setText(currentScore + 5);
- };
- self.addChild(statue);
+ var woodStatue = new WoodStatue();
+ woodStatue.x = 1500;
+ woodStatue.y = 2510;
+ self.addChild(woodStatue);
// Add text1 for wood score beside wood asset
var woodScoreText = new Text1();
woodScoreText.setText('0');
woodScoreText.x = wood.x - 90; // Position beside wood asset from the left
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, have "AD" not "$", hd colors. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows