Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'var tree = self.attachAsset('tree' + i, {' Line Number: 337
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'var tree = self.attachAsset('tree' + i, {' Line Number: 337
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'var tree = self.attachAsset('tree' + i, {' Line Number: 337
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'var tree = self.attachAsset('tree' + i, {' Line Number: 303
User prompt
Add tree1 2 3 4 5 6 7 8 to page 1. Make trees images can be dragged
User prompt
Add wall1 to page1 in bottom.
User prompt
Make gate1 go to page1
User prompt
Make gate2 go to page2
User prompt
Make gate3 go to page3
User prompt
make gate4 go to page4
User prompt
Make gate5 go to page5
User prompt
Make gate6 go to page6
User prompt
Why i can't make the gate as a button to go to page1!
User prompt
fix set 13
User prompt
Make the gate6 move with background0 when dragging its image.
User prompt
Can you fix that?
User prompt
Make the background0 is the background for page 0 and background1 for page1 so on
User prompt
Please fix the bug: 'Uncaught ReferenceError: background1 is not defined' in or related to this line: 'self.offset = {' Line Number: 77
User prompt
The gates are not navigating to there pages they go all to page1!
User prompt
Why background6 appearing when i drag background0! if that bug then fix it because background6 must be in page6 only.
User prompt
make background0 for page0 not background1 in page0
User prompt
Please fix the bug: 'Uncaught ReferenceError: background1 is not defined' in or related to this line: 'self.offset = {' Line Number: 77
User prompt
Make each gate can go to a page like gate1 to page1 so on
User prompt
check the pages if they are in game page1 2 3 4 5 6
/**** * 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 }); // 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; // Check if gate6 is at a specific position to navigate to Page6 if (gate6.x === 1024 && gate6.y === 1366) { page = game.addChild(new Page6()); } else if (gate5.x === 1024 && gate5.y === 1366) { // Check if gate5 is at a specific position to navigate to Page5 page = game.addChild(new Page5()); } else if (gate4.x === 1024 && gate4.y === 1366) { // Check if gate4 is at a specific position to navigate to Page4 page = game.addChild(new Page4()); } else if (gate3.x === 1024 && gate3.y === 1366) { // Check if gate3 is at a specific position to navigate to Page3 page = game.addChild(new Page3()); } else if (gate2.x === 1024 && gate2.y === 1366) { // Check if gate2 is at a specific position to navigate to Page2 page = game.addChild(new Page2()); } else if (gate1.x === 1024 && gate1.y === 1366) { // Check if gate1 is at a specific position to navigate to Page1 page = game.addChild(new Page1()); } }; self.move = function (x, y, obj) { if (self.dragging) { 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 self.initialClick = { x: x, y: 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 }); // 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 }); // 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 }); // 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 // 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 // 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 }); // Remove syncing of gate6's position with background0 to prevent background6 from appearing when dragging background0 }); // 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 'background2' with the anchor point set to 0, 0 var background1 = self.attachAsset('background1', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0 }); }); var Page2 = 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 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 'background4' 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 'background5' 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 'background6' 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 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ //{0.1} game.update = function () { //{0.2} if (page instanceof Page1) { //{0.3} console.log("The game is on Page1"); //{0.4} } else if (page instanceof Page2) { //{0.5} console.log("The game is on Page2"); //{0.6} } else if (page instanceof Page3) { //{0.7} console.log("The game is on Page3"); //{0.8} } else if (page instanceof Page4) { //{0.9} console.log("The game is on Page4"); //{0.a} } else if (page instanceof Page5) { //{0.b} console.log("The game is on Page5"); //{0.c} } else if (page instanceof Page6) { //{0.d} console.log("The game is on Page6"); //{0.e} } //{0.f} }; //{0.g} //{0.b} var page = game.addChild(new Page0()); //{0.b} ; //{0.b}
===================================================================
--- original.js
+++ change.js
@@ -30,27 +30,22 @@
self.data = null;
// Check if gate6 is at a specific position to navigate to Page6
if (gate6.x === 1024 && gate6.y === 1366) {
page = game.addChild(new Page6());
- }
- // Check if gate5 is at a specific position to navigate to Page5
- if (gate5.x === 1024 && gate5.y === 1366) {
+ } else if (gate5.x === 1024 && gate5.y === 1366) {
+ // Check if gate5 is at a specific position to navigate to Page5
page = game.addChild(new Page5());
- }
- // Check if gate4 is at a specific position to navigate to Page4
- if (gate4.x === 1024 && gate4.y === 1366) {
+ } else if (gate4.x === 1024 && gate4.y === 1366) {
+ // Check if gate4 is at a specific position to navigate to Page4
page = game.addChild(new Page4());
- }
- // Check if gate3 is at a specific position to navigate to Page3
- if (gate3.x === 1024 && gate3.y === 1366) {
+ } else if (gate3.x === 1024 && gate3.y === 1366) {
+ // Check if gate3 is at a specific position to navigate to Page3
page = game.addChild(new Page3());
- }
- // Check if gate2 is at a specific position to navigate to Page2
- if (gate2.x === 1024 && gate2.y === 1366) {
+ } else if (gate2.x === 1024 && gate2.y === 1366) {
+ // Check if gate2 is at a specific position to navigate to Page2
page = game.addChild(new Page2());
- }
- // Check if gate1 is at a specific position to navigate to Page1
- if (gate1.x === 1024 && gate1.y === 1366) {
+ } else if (gate1.x === 1024 && gate1.y === 1366) {
+ // Check if gate1 is at a specific position to navigate to Page1
page = game.addChild(new Page1());
}
};
self.move = function (x, y, obj) {
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