User prompt
Please fix the bug: 'planet.getGlobalBounds is not a function' in or related to this line: 'var planetBounds = planet.getGlobalBounds();' Line Number: 109
User prompt
Please fix the bug: 'planet.getBounds is not a function' in or related to this line: 'var planetBounds = planet.getBounds();' Line Number: 109
User prompt
crea una función para sistema solar
User prompt
crea una función que detecte si un planeta esta dentro del rango de area
User prompt
agrega area a la galaxia
User prompt
crea una función reusable para Solarsystem que al tocarlo se detecte como visitado
User prompt
arregla el bug que desaparece solarsystem
User prompt
el objeto sigue desapareciendo al cambiar de asset
User prompt
arregla el bug que desaparece el sistema solar cuando cambia a visitado
Code edit (1 edits merged)
Please save this source code
User prompt
crea una función reusable para Solarsystem que al tocarlo se detecte como visitado y cambie su diseño
User prompt
solar sistem no cambia a visitado al tocarlo
User prompt
al interactuar con solarSystem (excluye initial) visitedsystem =true
User prompt
Please fix the bug: 'Uncaught TypeError: obj.setTexture is not a function' in or related to this line: 'obj.setTexture('visitedSolarSystem');' Line Number: 43
User prompt
Cuando se toque sistema solar se vuelve visitado
User prompt
haz que al tocar un sistema solar (excluyendo el inicial) se vuelva un planeta visitado
User prompt
haz que al tocar un sistema solar (excluyendo el inicial) se detecte como visitado
User prompt
crea una función reusable para solarSystem para crear una mecanica de visita
User prompt
aplica esto mismo a initialsolarsystem
Code edit (3 edits merged)
Please save this source code
User prompt
haz changeSizeOnTouc funcional
Code edit (1 edits merged)
Please save this source code
User prompt
add a new object with the asset solarsystem
User prompt
haz que changesizeontouch funcione con todas las galaxias
Code edit (1 edits merged)
Please save this source code
/**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Create initial solar system var initialSolarSystem = game.addChild(LK.getAsset('initialSolarSystem', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 })); // Apply changeSizeOnTouch to the initialSolarSystem object changeSizeOnTouch(initialSolarSystem, 0.9); // Add a new solar system object var SolarSystem = game.addChild(LK.getAsset('solarSystem', { anchorX: 0.5, anchorY: 0.5, x: 512, y: 683 })); // Apply changeSizeOnTouch to the SolarSystem object changeSizeOnTouch(SolarSystem, 0.9); // Function to change the size of an object when touched and restore it when released // Also, mark the SolarSystem as visited when touched function changeSizeOnTouch(obj, scaleFactor) { obj.down = function (x, y, touchedObj) { obj.scaleX = scaleFactor; obj.scaleY = scaleFactor; // If the object is a SolarSystem, mark it as visited if (obj === SolarSystem) { obj.asset = LK.getAsset('visitedSolarSystem', {}); } }; obj.up = function (x, y, touchedObj) { obj.scaleX = 1; obj.scaleY = 1; }; } // Function to enable optimized galaxy motion for a given object function enableGalaxyMotion(obj) { var dragNode = null; var velocity = { x: 0, y: 0 }; var lastPosition = { x: 0, y: 0 }; obj.down = function (x, y, touchedObj) { dragNode = obj; lastPosition.x = x; lastPosition.y = y; }; obj.move = function (x, y, touchedObj) { if (dragNode) { velocity.x = (x - lastPosition.x) * 0.6 + velocity.x * 0.8; velocity.y = (y - lastPosition.y) * 0.6 + velocity.y * 0.8; dragNode.x += velocity.x; dragNode.y += velocity.y; lastPosition.x = x; lastPosition.y = y; } }; obj.up = function (x, y, touchedObj) { dragNode = null; }; } // Add an area to the galaxy var area = game.addChild(LK.getAsset('area', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 })); // Apply galaxy motion to the entire game area enableGalaxyMotion(game);
===================================================================
--- original.js
+++ change.js
@@ -71,6 +71,13 @@
obj.up = function (x, y, touchedObj) {
dragNode = null;
};
}
+// Add an area to the galaxy
+var area = game.addChild(LK.getAsset('area', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1366
+}));
// Apply galaxy motion to the entire game area
enableGalaxyMotion(game);
\ No newline at end of file