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
/**** * Classes ****/ // Create a SolarSystem class by using the LK expand method to extend Container. var SolarSystem = Container.expand(function () { var self = Container.call(this); // Get and automatically addChild to self asset with id 'solarSystem' with the anchor point set to .5, .5 var solarSystemGraphics = self.attachAsset('solarSystem', { anchorX: 0.5, anchorY: 0.5 }); solarSystemGraphics.rotation = Math.PI; // Rotation are in radians solarSystemGraphics.alpha = .8; // Get actual size of asset. console.log(solarSystemGraphics.width, solarSystemGraphics.height); }); /**** * 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(new SolarSystem()); solarSystem.x = 512; solarSystem.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); // Function to detect if a planet is within the area range function isPlanetInArea(planet, area) { var planetBounds = planet.getBounds(); var areaBounds = area.getGlobalBounds(); return areaBounds.contains(planetBounds.x, planetBounds.y); } // Check if the SolarSystem is within the area console.log(isPlanetInArea(SolarSystem, area));
===================================================================
--- original.js
+++ change.js
@@ -96,9 +96,9 @@
// Apply galaxy motion to the entire game area
enableGalaxyMotion(game);
// Function to detect if a planet is within the area range
function isPlanetInArea(planet, area) {
- var planetBounds = planet.getGlobalBounds();
+ var planetBounds = planet.getBounds();
var areaBounds = area.getGlobalBounds();
return areaBounds.contains(planetBounds.x, planetBounds.y);
}
// Check if the SolarSystem is within the area