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 (2 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
User prompt
aumenta la sensibilidad de movimiento para que sea más suave
User prompt
haz que la función no se ejecute al tocar un objeto y funcione al tocar cualquier posición de la galaxia
User prompt
el movimiento de los objetos es errático
User prompt
la función funciona horrible, el calculo se hace mal y el movimiento no es perfecto, utiliza otro metodo más optimo
User prompt
haz que afecte los sistemas solares
User prompt
haz que enablegalaxymotion sea una función reusable para arrastrar la galaxia
Code edit (1 edits merged)
Please save this source code
User prompt
create a new reusable function called enableGalaxyMotion
/**** * 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); // Apply markAsVisited to the SolarSystem object markAsVisited(SolarSystem); // Function to change the size of an object when touched and restore it when released function changeSizeOnTouch(obj, scaleFactor) { obj.down = function (x, y, touchedObj) { obj.scaleX = scaleFactor; obj.scaleY = scaleFactor; }; obj.up = function (x, y, touchedObj) { obj.scaleX = 1; obj.scaleY = 1; }; } // Function to mark a SolarSystem as visited and change its design function markAsVisited(obj) { obj.down = function (x, y, touchedObj) { obj.setAsset('visitedSolarSystem', { anchorX: 0.5, anchorY: 0.5, x: obj.x, y: obj.y, scaleX: obj.scaleX, scaleY: obj.scaleY }); }; } // 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; }; } // Apply galaxy motion to the entire game area enableGalaxyMotion(game);
===================================================================
--- original.js
+++ change.js
@@ -43,9 +43,13 @@
function markAsVisited(obj) {
obj.down = function (x, y, touchedObj) {
obj.setAsset('visitedSolarSystem', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ x: obj.x,
+ y: obj.y,
+ scaleX: obj.scaleX,
+ scaleY: obj.scaleY
});
};
}
// Function to enable optimized galaxy motion for a given object