User prompt
Please fix the bug: 'Uncaught TypeError: tree2.hide is not a function' in or related to this line: 'tree2.hide();' Line Number: 487
User prompt
Hide the tree2 not statue!
User prompt
Hide the tree2 after 3 clicks on its statue
User prompt
Add same statue of tree1 to the tree2 that is beside it from the left side
User prompt
Remove statue from any tree except tree1
User prompt
Remove statue2
User prompt
Make the statue2 as statue1
User prompt
Please fix the bug: 'Uncaught ReferenceError: woodScoreText is not defined' in or related to this line: 'woodScoreText.setText(totalStatueScore);' Line Number: 850
User prompt
Add statue2 to the middle of page1
User prompt
Add object statue2 as the object of statue1 with same system.
User prompt
Add the statue class
User prompt
Remove duplication of statue
User prompt
Add it to game
User prompt
Add statue2 to page1
User prompt
Move statue2 to tree2
User prompt
Duplicate statue1 object as statue2 object for tree2
User prompt
Remove any statue tree except of tree1
User prompt
Add statue2 to tree2
User prompt
Move reposition the statue in each tree tre2 3 4 5 6 7 8
User prompt
Add duplicate statue1 as statue2 to tree2 then make same for other trees in page1.
User prompt
check the trees if they have statue as tree1 to hide by it after3 clicks on it.
User prompt
check if there's class of trees and there status
User prompt
Fix the duplication of statue of any tree or duplication of trees!
User prompt
Make the statue2 can hide tree2 like statue1 hide tree1!
User prompt
Remove what's preventing tree2 from hide from the screen.
/**** * 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 '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, // Sync initial x position with background0 y: background0.y // Sync initial y position with background0 }); self.addChild(woodarea); 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"); } 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 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 }); var tree2 = new Tree('tree2', 700, 1366); self.addChild(tree2); // Add statue2 to tree2 image var statue2 = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree2.x + 477, // Position statue2 to the right of tree2 y: tree2.y - 660 // Move statue2 up by 100 units }); self.addChild(statue2); // Initialize click count for statue2 // Add click event to statue2 to increase score and update text statue2.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); tree2.incrementClickCount(); if (tree2.getClickCount() >= 3) { tree2.hide(); statue2.visible = false; } }; var tree3 = new Tree('tree3', 380, 1366); self.addChild(tree3); // Add statue3 to tree3 image var statue3 = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree3.x + 477, // Position statue3 to the right of tree3 y: tree3.y - 660 // Move statue3 up by 100 units }); self.addChild(statue3); // Add click event to statue3 to increase score and update text statue3.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); tree3.incrementClickCount(); if (tree3.getClickCount() >= 3) { tree3.hide(); statue3.visible = false; } }; var tree4 = new Tree('tree4', 100, 1366); self.addChild(tree4); // Add statue4 to tree4 image var statue4 = self.attachAsset('statue', { anchorX: 0.5, //{24.1} anchorY: 0.5, //{24.2} x: tree4.x + 477, //{24.3} y: tree4.y - 660 // Move statue4 up by 100 units//{24.4} }); //{24.5} self.addChild(statue4); // Add click event to statue4 to increase score and update text statue4.down = function (x, y, obj) { totalStatueScore += 5; //{24.6} woodScoreText.setText(totalStatueScore); //{24.7} tree4.incrementClickCount(); if (tree4.getClickCount() >= 3) { tree4.hide(); statue4.visible = false; } //{24.8} }; var tree5 = new Tree('tree5', 1000, 1666); self.addChild(tree5); // Add statue5 to tree5 image var statue5 = self.attachAsset('statue', { anchorX: 0.5, //{2a.1} anchorY: 0.5, //{2a.2} x: tree5.x + 477, //{2a.3} y: tree5.y - 660 // Move statue5 up by 100 units//{2a.4} }); //{2a.5} self.addChild(statue5); // Add click event to statue5 to increase score and update text statue5.down = function (x, y, obj) { totalStatueScore += 5; //{2a.6} woodScoreText.setText(totalStatueScore); //{2a.7} tree5.incrementClickCount(); if (tree5.getClickCount() >= 3) { tree5.hide(); statue5.visible = false; } //{2a.8} }; var tree6 = new Tree('tree6', 700, 1666); self.addChild(tree6); // Add statue6 to tree6 image var statue6 = self.attachAsset('statue', { anchorX: 0.5, //{2i.1} anchorY: 0.5, //{2i.2} x: tree6.x + 477, //{2i.3} y: tree6.y - 660 // Move statue6 up by 100 units//{2i.4} }); //{2i.5} self.addChild(statue6); // Add click event to statue6 to increase score and update text statue6.down = function (x, y, obj) { totalStatueScore += 5; //{2i.6} woodScoreText.setText(totalStatueScore); //{2i.7} tree6.incrementClickCount(); if (tree6.getClickCount() >= 3) { tree6.hide(); statue6.visible = false; } //{2i.8} }; var tree7 = new Tree('tree7', 380, 1666); self.addChild(tree7); // Add statue7 to tree7 image var statue7 = self.attachAsset('statue', { anchorX: 0.5, //{2q.1} anchorY: 0.5, //{2q.2} x: tree7.x + 477, //{2q.3} y: tree7.y - 660 // Move statue7 up by 100 units//{2q.4} }); //{2q.5} self.addChild(statue7); // Add click event to statue7 to increase score and update text statue7.down = function (x, y, obj) { totalStatueScore += 5; //{2q.6} woodScoreText.setText(totalStatueScore); //{2q.7} tree7.incrementClickCount(); if (tree7.getClickCount() >= 3) { tree7.hide(); statue7.visible = false; } //{2q.8} }; var tree8 = new Tree('tree8', 80, 1666); self.addChild(tree8); // Add statue8 to tree8 image var statue8 = self.attachAsset('statue', { anchorX: 0.5, //{2y.1} anchorY: 0.5, //{2y.2} x: tree8.x + 477, //{2y.3} y: tree8.y - 660 // Move statue8 up by 100 units//{2y.4} }); //{2y.5} self.addChild(statue8); // Add click event to statue8 to increase score and update text statue8.down = function (x, y, obj) { totalStatueScore += 5; //{2y.6} woodScoreText.setText(totalStatueScore); //{2y.7} tree8.incrementClickCount(); if (tree8.getClickCount() >= 3) { tree8.hide(); statue8.visible = false; } //{2y.8} }; var tree1_below = new Tree('tree1', 1000, 1966); self.addChild(tree1_below); // Add statue to tree1_below var statue1_below = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree1_below.x + 477, y: tree1_below.y - 660 }); self.addChild(statue1_below); statue1_below.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; var tree2_below = new Tree('tree2', 700, 1966); self.addChild(tree2_below); // Add statue to tree2_below var statue2_below = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree2_below.x + 477, y: tree2_below.y - 660 }); self.addChild(statue2_below); statue2_below.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; var tree3_below = new Tree('tree3', 380, 1966); self.addChild(tree3_below); // Add statue to tree3_below var statue3_below = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree3_below.x + 477, y: tree3_below.y - 660 }); self.addChild(statue3_below); statue3_below.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; var tree4_below = new Tree('tree4', 80, 1966); self.addChild(tree4_below); // Add statue to tree4_below var statue4_below = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree4_below.x + 477, y: tree4_below.y - 660 }); self.addChild(statue4_below); statue4_below.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; var tree5_below = new Tree('tree5', 1000, 2266); self.addChild(tree5_below); // Add statue to tree5_below var statue5_below = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree5_below.x + 477, y: tree5_below.y - 660 }); self.addChild(statue5_below); statue5_below.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; var tree6_below = new Tree('tree6', 700, 2266); self.addChild(tree6_below); // Add statue to tree6_below var statue6_below = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree6_below.x + 477, y: tree6_below.y - 660 }); self.addChild(statue6_below); statue6_below.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; var tree7_below = new Tree('tree7', 380, 2266); self.addChild(tree7_below); // Add statue to tree7_below var statue7_below = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree7_below.x + 477, y: tree7_below.y - 660 }); self.addChild(statue7_below); statue7_below.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; var tree8_below = new Tree('tree8', 80, 2266); self.addChild(tree8_below); // Add statue to tree8_below var statue8_below = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree8_below.x + 477, y: tree8_below.y - 660 }); self.addChild(statue8_below); statue8_below.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; var tree1_below2 = new Tree('tree1', 1000, 2566); self.addChild(tree1_below2); // Add statue to tree1_below2 var statue1_below2 = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree1_below2.x + 477, y: tree1_below2.y - 660 }); self.addChild(statue1_below2); statue1_below2.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; var statue1 = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: 1000 + 477, // Position statue1 to the right of tree1 y: 1366 - 660 // Move statue1 up by 100 units }); self.addChild(statue1); var tree1 = self.attachAsset('tree1', { anchorX: -1.1, anchorY: 3, x: 1000, // Align horizontally with tree5 y: 1366 // Position tree1 above tree5 }); // Add half_tree to tree1 var halfTree1 = self.attachAsset('half_tree', { anchorX: -6.65, anchorY: 10.2, x: tree1.x + 50, // Position half_tree1 slightly to the right of tree1 y: tree1.y - 50 // Position half_tree1 slightly above tree1 }); self.addChild(halfTree1); tree1.clickCount = 0; self.addChild(tree1); statue1.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); tree1.clickCount += 1; if (tree1.clickCount >= 3) { tree1.visible = false; statue1.visible = false; } }; var tree3 = self.attachAsset('tree3', { anchorX: -1.1, anchorY: 3, x: 380, y: 1366 }); tree3.clickCount = 0; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; var tree2_below2 = new Tree('tree2', 700, 2566); self.addChild(tree2_below2); // Add statue to tree2_below2 var statue2_below2 = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree2_below2.x + 477, y: tree2_below2.y - 660 }); self.addChild(statue2_below2); statue2_below2.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); tree2_below2.incrementClickCount(); if (tree2_below2.getClickCount() >= 3) { tree2_below2.hide(); statue2_below2.visible = false; } }; var tree3_below2 = new Tree('tree3', 380, 2566); self.addChild(tree3_below2); // Add statue to tree3_below2 var statue3_below2 = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree3_below2.x + 477, y: tree3_below2.y - 660 }); self.addChild(statue3_below2); statue3_below2.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; var tree4_below2 = new Tree('tree4', 80, 2566); self.addChild(tree4_below2); // Add statue to tree4_below2 var statue4_below2 = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: tree4_below2.x + 477, y: tree4_below2.y - 660 }); self.addChild(statue4_below2); statue4_below2.down = function (x, y, obj) { totalStatueScore += 5; woodScoreText.setText(totalStatueScore); }; 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; 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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; // 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 beside wood asset var statue = self.attachAsset('statue', { anchorX: 0.5, anchorY: 0.5, x: 2002, // Position statue to the right of the wood y: 2510 // Align vertically with wood }); // Add text for wood score beside wood asset var woodScoreText = new Text2('0', { size: 70, fill: 0x471e00 }); woodScoreText.anchor.set(1, 0.5); woodScoreText.x = wood.x - 90; // Position text to the left of the wood woodScoreText.y = wood.y; self.addChild(woodScoreText); // Hide the statue beside the wood statue.visible = false; 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) { silver.clickCount += 5; silverScoreText.setText(silver.clickCount); }; 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) { stone.clickCount += 5; stoneScoreText.setText(stone.clickCount); }; 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) { gold.clickCount += 5; goldScoreText.setText(gold.clickCount); }; 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) { bronze.clickCount += 5; bronzeScoreText.setText(bronze.clickCount); }; 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) { crystal.clickCount += 5; crystalScoreText.setText(crystal.clickCount); }; 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); // 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 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 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; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var totalStatueScore = 0; // Initialize totalStatueScore to fix ReferenceError var page = game.addChild(new Page0()); //{0.b} ; //{0.b}
===================================================================
--- original.js
+++ change.js
@@ -223,8 +223,13 @@
// Add click event to statue3 to increase score and update text
statue3.down = function (x, y, obj) {
totalStatueScore += 5;
woodScoreText.setText(totalStatueScore);
+ tree3.incrementClickCount();
+ if (tree3.getClickCount() >= 3) {
+ tree3.hide();
+ statue3.visible = false;
+ }
};
var tree4 = new Tree('tree4', 100, 1366);
self.addChild(tree4);
// Add statue4 to tree4 image
@@ -241,9 +246,14 @@
// Add click event to statue4 to increase score and update text
statue4.down = function (x, y, obj) {
totalStatueScore += 5; //{24.6}
woodScoreText.setText(totalStatueScore); //{24.7}
- }; //{24.8}
+ tree4.incrementClickCount();
+ if (tree4.getClickCount() >= 3) {
+ tree4.hide();
+ statue4.visible = false;
+ } //{24.8}
+ };
var tree5 = new Tree('tree5', 1000, 1666);
self.addChild(tree5);
// Add statue5 to tree5 image
var statue5 = self.attachAsset('statue', {
@@ -259,9 +269,14 @@
// Add click event to statue5 to increase score and update text
statue5.down = function (x, y, obj) {
totalStatueScore += 5; //{2a.6}
woodScoreText.setText(totalStatueScore); //{2a.7}
- }; //{2a.8}
+ tree5.incrementClickCount();
+ if (tree5.getClickCount() >= 3) {
+ tree5.hide();
+ statue5.visible = false;
+ } //{2a.8}
+ };
var tree6 = new Tree('tree6', 700, 1666);
self.addChild(tree6);
// Add statue6 to tree6 image
var statue6 = self.attachAsset('statue', {
@@ -277,9 +292,14 @@
// Add click event to statue6 to increase score and update text
statue6.down = function (x, y, obj) {
totalStatueScore += 5; //{2i.6}
woodScoreText.setText(totalStatueScore); //{2i.7}
- }; //{2i.8}
+ tree6.incrementClickCount();
+ if (tree6.getClickCount() >= 3) {
+ tree6.hide();
+ statue6.visible = false;
+ } //{2i.8}
+ };
var tree7 = new Tree('tree7', 380, 1666);
self.addChild(tree7);
// Add statue7 to tree7 image
var statue7 = self.attachAsset('statue', {
@@ -295,9 +315,14 @@
// Add click event to statue7 to increase score and update text
statue7.down = function (x, y, obj) {
totalStatueScore += 5; //{2q.6}
woodScoreText.setText(totalStatueScore); //{2q.7}
- }; //{2q.8}
+ tree7.incrementClickCount();
+ if (tree7.getClickCount() >= 3) {
+ tree7.hide();
+ statue7.visible = false;
+ } //{2q.8}
+ };
var tree8 = new Tree('tree8', 80, 1666);
self.addChild(tree8);
// Add statue8 to tree8 image
var statue8 = self.attachAsset('statue', {
@@ -313,9 +338,14 @@
// Add click event to statue8 to increase score and update text
statue8.down = function (x, y, obj) {
totalStatueScore += 5; //{2y.6}
woodScoreText.setText(totalStatueScore); //{2y.7}
- }; //{2y.8}
+ tree8.incrementClickCount();
+ if (tree8.getClickCount() >= 3) {
+ tree8.hide();
+ statue8.visible = false;
+ } //{2y.8}
+ };
var tree1_below = new Tree('tree1', 1000, 1966);
self.addChild(tree1_below);
// Add statue to tree1_below
var statue1_below = self.attachAsset('statue', {
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
Flat cleared desert have a squares with lines inside all of it 200x200 Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows