User prompt
Crea una logica para que la zona de aparición de los sistemas se generen dentro de un rango circular
User prompt
siguen apareciendo sistemas con nombres repetidos
User prompt
arregla los nombres de los sistemas para que no se repitan
User prompt
la animación no esta en bucle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
haz que sea en bucle y sea una transición entre 0 a 1 y viceversa ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
agrega una animación de trasparencia para conection line ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
al tocar boton que cambie la escena la principal
User prompt
Desactiva la función de movimiento en la newpage
User prompt
elimina la función reusable de rouch
User prompt
haz que la interacción con boton no se por medio de una función reusable
User prompt
boton no es interactuable
User prompt
boton no funciona
User prompt
cuando se presione button que establezca fuel en 1 y que cambie a la pagina principal
User prompt
haz que boton sea interactuable
User prompt
cuando se colisiona con un sistema cambia pagina a newpage y oculta toda la pagina inicial
User prompt
haz que new page solo sea visible despues de estar en un sistema
User prompt
haz que charge station visible = true cuando se esta en un sistema y cuando no false
User prompt
asignale de nombre a la nueva pagina "charge station"
User prompt
haz que new page solo sea visible al estar en un sistema
User prompt
haz que new page solo tenga boton asset
User prompt
crea una nueva pagina separada de las demás
User prompt
agrega un nuevo objeto con el asset boton en la parte inferior de la pantalla y que funcione como interfaz visible
User prompt
agrega un nuevo objeto con el asset boton en la parte inferior de la pantalla y que funcione como interfaz
User prompt
button no se muestra en escena
===================================================================
--- original.js
+++ change.js
@@ -16,12 +16,20 @@
width: Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)),
height: LK.getAsset('connectSolarSystem', {}).height,
rotation: Math.atan2(y2 - y1, x2 - x1),
anchorX: 0,
- anchorY: 0.5,
- alpha: 0.3
+ anchorY: 0.5
});
self.addChild(line);
+ tween(line, {
+ alpha: 0
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ line.alpha = 1;
+ }
+ });
};
// Array to keep track of visited solar systems
self.visitedSolarSystems = [];
// Function to connect visited solar systems
@@ -50,39 +58,8 @@
var MidgroundContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
-var NewPage = Container.expand(function () {
- var self = Container.call(this);
- // Add a button asset to the new page
- var button = self.attachAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 1024,
- y: 1366
- });
- // Disable interactivity for the button
- button.interactive = true; // Enable button interactivity
- button.buttonMode = true; // Change cursor when hovering over the button
- button.down = function (x, y, obj) {
- console.log("Button pressed at", x, y);
- fuel = 1; // Set fuel to 1 when the button is pressed
- game.children.forEach(function (child) {
- if (child !== newPage) {
- child.visible = true; // Show all initial page elements
- }
- });
- game.removeChild(newPage); // Remove NewPage from the game
- game.addChild(backgroundContainer); // Add backgroundContainer back to the game
- game.addChild(midgroundContainer); // Add midgroundContainer back to the game
- game.addChild(foregroundContainer); // Add foregroundContainer back to the game
- };
- button.up = function (x, y, obj) {
- console.log("Button released at", x, y);
- // Logic for button release can be added here if needed
- };
- return self;
-});
var SolarSystem = Container.expand(function () {
var self = Container.call(this);
var solarSystemGraphics = self.attachAsset('solarSystem', {
anchorX: 0.5,
@@ -100,28 +77,12 @@
/****
* Game Code
****/
-var newPage = new NewPage(); // Initialize NewPage but do not add it to the game yet
-var fuel = 1; // Initial fuel level set to 1
-// Function to check if all solar systems are part of the network
-function verifyNetworkCompleteness() {
- return network.every(function (solarSystem) {
- return solarSystem.visited;
- });
-}
var initialSolarSystem = {
x: 0,
y: 0
}; // Define initialSolarSystem with default coordinates
-// Create a text display to show network connection status
-var networkStatusText = new Text2('Network Status: Disconnected', {
- size: 50,
- fill: 0xFFFFFF
-});
-networkStatusText.anchor.set(0.5, 0); // Center the text horizontally at the top
-LK.gui.top.addChild(networkStatusText); // Add to GUI overlay
-// LK.gui.top.center.addChild(networkStatusText); // Center the text at the top
var punterPreviousSystem = 0; // Variable to store the planet number where the router is located
var visitedSolarSystems = [];
// Removed global connectVisitedSolarSystems function and use BackgroundContainer's method
var backgroundContainer = game.addChild(new BackgroundContainer());
@@ -131,36 +92,16 @@
spaceShip.x = area.x;
spaceShip.y = area.y;
// Update game logic to connect solar systems using BackgroundContainer's methods
backgroundContainer.visitedSolarSystems = visitedSolarSystems;
- backgroundContainer.connectVisitedSolarSystems(); // Connect visited solar systems
- // Check if the spaceship has visited a solar system and add NewPage to the game
- if (visitedSolarSystems.length > 0 && !game.children.includes(newPage)) {
- game.addChild(newPage);
- }
- // Update network status text based on network completeness
- if (verifyNetworkCompleteness()) {
- networkStatusText.setText('Network Status: Connected');
- } else {
- networkStatusText.setText('Network Status: Disconnected');
- }
+ backgroundContainer.connectVisitedSolarSystems();
// Update game logic to connect solar systems
game.update = function () {
spaceShip.x = area.x;
spaceShip.y = area.y;
// Check for collision between areaPunter and each solarSystem
network.forEach(function (solarSystem) {
if (spaceShip.intersects(solarSystem)) {
- // Hide all initial page elements
- game.children.forEach(function (child) {
- if (child !== newPage) {
- child.visible = false;
- }
- });
- // Add NewPage to the game if not already added
- if (!game.children.includes(newPage)) {
- game.addChild(newPage);
- }
punterPreviousSystem = solarSystemList.find(function (system) {
return system.solarSystem === solarSystem;
}).id; // Update punterSystem with the ID
// Change the sprite to visitedSolarSystem
@@ -272,18 +213,25 @@
midgroundContainer.addChild(solarSystemText);
// Apply changeSizeOnTouch to each SolarSystem object
solarSystem.down = function (x, y, touchedObj) {
changeAreaLocation(solarSystem, area);
- var originalScaleX = solarSystem.scaleX;
- var originalScaleY = solarSystem.scaleY;
- solarSystem.scaleX = originalScaleX * 0.9;
- solarSystem.scaleY = originalScaleY * 0.9;
- solarSystem.up = function (x, y, touchedObj) {
- solarSystem.scaleX = originalScaleX;
- solarSystem.scaleY = originalScaleY;
- };
+ 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, scale) {
+ var originalScaleX = obj.scaleX;
+ var originalScaleY = obj.scaleY;
+ obj.down = function (x, y, touchedObj) {
+ this.scaleX = originalScaleX * scale;
+ this.scaleY = originalScaleY * scale;
+ };
+ obj.up = function (x, y, touchedObj) {
+ this.scaleX = originalScaleX;
+ this.scaleY = originalScaleY;
+ };
+}
// Function to enable optimized galaxy motion for a given object
function enableGalaxyMotion(obj) {
var dragNode = null;
var velocity = {
@@ -363,11 +311,11 @@
// Apply galaxy motion to the entire game area
enableGalaxyMotion(game);
// Function to change the area's location to the touched solar system
function changeAreaLocation(solarSystem, area) {
- if (area.isMoving || fuel < 1) {
+ if (area.isMoving) {
return;
- } // Prevent relocation if already moving or if fuel is insufficient
+ } // Prevent relocation if already moving
// Check if the solar system is within the area
var dx = solarSystem.x - area.x;
var dy = solarSystem.y - area.y;
var distance = Math.sqrt(dx * dx + dy * dy);
@@ -390,9 +338,8 @@
duration: duration,
easing: tween.easeInOut,
onFinish: function onFinish() {
area.isMoving = false; // Reset moving flag
- fuel = 0; // Set fuel to 0 when spaceship reaches a new solar system
LK.getSound('movesound').stop(); // Stop movesound when the spaceship reaches its destination
// Calculate a unique pitch based on the solar system's ID
var pitch = 1 + punterPreviousSystem % 10 * 0.1; // Example: vary pitch between 1.0 and 2.0
LK.getSound('visitedsound').play({