User prompt
Colócale una buena música de fondo y efectos de sonido
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('gameTitle', {' Line Number: 295
User prompt
Hazlo un poco más pequeña para que se entienda y agregalo a activos para yo reemplazarlo a mi gusto
User prompt
Colócalo un poco más grande y coloca la h en mayúscula y está ves escríbelo con una tipografía pixel para un juego retro
User prompt
En ves del título space dodger agrega "hasta el infinito y más allá" y has con letras amarillas en un formato de caligrafía retro
User prompt
El botón de disparo no se dispara corrige eso y has que al presionarlo salga del avión un proyectil que elimine los asteroides ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que el botón naranja sea un botón de disparo para disparar un proyectil y poder explotar un asteroide y has q el botón solo se pueda usar cada 15 segundos y agrega una animación de carga para indicar cuándo se puede volver a usar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Colócalos mas arriba de manera dónde se vean pero que no interfiera con el contador de tiempo
User prompt
Coloca los corazones un poco más abajo para que se puedan ver un poco mejor
User prompt
Has que el avión haga un dash al presionar el botón de impulso ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mueve los corazones a la parte de arriba del contador del tiempo para que no interfieran con la visión del contador de monedas
User prompt
Has que el avion tenga una animación de velocidad que lo tenga eleve más arriba al presionar el botón de impulso ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has un sistema de tres corazones en el juego y un poder que caiga cada 25 segundos que al atraparlo te haga inmune durante 10 segundos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has una música para el juego y un sonido al perder y al agarrar las monedas
User prompt
Has un poder para que el avion acelere por 20 segundos y has una animación de aceleración ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que las palabras en los botones no se vean y coloca solo los activos de colores para yo poder sustituirlos por imágenes coloca el activo del botón de inicio también
User prompt
Has monedas en la partida para recolectar ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
Has que cada 10 segundos la velocidad del avión aumente así como la de la caída de objetos para aumentar la velocidad del juego y así su dificultad
User prompt
El avión coliciona antes de llegar completamente al meteorito o escombro corrige eso y has que solo pierda si las dos imágenes se tocan correctamente
User prompt
Coloca en el menú un botón donde lleve a un apartado diferente dónde puedas elegir otro tipo de avión disponible para jugar en partida ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Has que el avión solo pierda si toca a un meteorito o escombro
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(self.scale, 200, {' Line Number: 83 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'storage.get is not a function' in or related to this line: 'var sensitivity = storage.get('sensitivity') || 1.0;' Line Number: 219 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Has un menú donde pongas un botón de iniciar partida, otro botón para ajustar la sensibilidad de la barra y decora
User prompt
Has que la barra de la parte de abajo sea más grande para poder manejarla mejor
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var BackButton = Container.expand(function () {
var self = Container.call(this);
var buttonBg = self.attachAsset('backButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
tween(self.scale, {
x: 0.9,
y: 0.9
}, {
duration: 200
});
};
self.up = function (x, y, obj) {
tween(self.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
};
return self;
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.lastY = undefined;
self.update = function () {
self.y += self.speed;
// Add floating animation
self.x += Math.sin(LK.ticks * 0.1 + self.y * 0.01) * 0.5;
// Add rotation
graphics.rotation += 0.05;
};
return self;
});
var Debris = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('debris', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 6;
self.lastY = undefined;
self.update = function () {
self.y += self.speed;
};
return self;
});
var MenuButton = Container.expand(function (color) {
var self = Container.call(this);
var buttonBg = self.attachAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5
});
if (color) buttonBg.tint = color;
self.down = function (x, y, obj) {
tween(self.scale, {
x: 0.9,
y: 0.9
}, {
duration: 200
});
};
self.up = function (x, y, obj) {
tween(self.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
};
return self;
});
var Meteorite = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('meteorite', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.lastY = undefined;
self.update = function () {
self.y += self.speed;
};
return self;
});
var SensitivitySlider = Container.expand(function () {
var self = Container.call(this);
var sliderBar = self.attachAsset('sensSlider', {
anchorX: 0.5,
anchorY: 0.5
});
var sliderHandle = self.addChild(LK.getAsset('sensHandle', {
anchorX: 0.5,
anchorY: 0.5
}));
self.minX = -280;
self.maxX = 280;
self.isDragging = false;
self.down = function (x, y, obj) {
self.isDragging = true;
self.updateHandle(x);
};
self.up = function (x, y, obj) {
self.isDragging = false;
};
self.updateHandle = function (x) {
var localX = x - self.x;
localX = Math.max(self.minX, Math.min(self.maxX, localX));
sliderHandle.x = localX;
};
self.getSensitivity = function () {
return (sliderHandle.x + 280) / 560; // 0 to 1
};
self.setSensitivity = function (value) {
sliderHandle.x = value * 560 - 280;
};
return self;
});
var SettingsButton = Container.expand(function () {
var self = Container.call(this);
var buttonBg = self.attachAsset('settingsButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
tween(self.scale, {
x: 0.9,
y: 0.9
}, {
duration: 200
});
};
self.up = function (x, y, obj) {
tween(self.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
};
return self;
});
var Spaceship = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('spaceship', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var StartButton = Container.expand(function () {
var self = Container.call(this);
var buttonBg = self.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
tween(self.scale, {
x: 0.9,
y: 0.9
}, {
duration: 200
});
};
self.up = function (x, y, obj) {
tween(self.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
};
return self;
});
var TouchSlider = Container.expand(function () {
var self = Container.call(this);
var sliderBar = self.attachAsset('sliderBar', {
anchorX: 0.5,
anchorY: 0.5
});
var sliderHandle = self.addChild(LK.getAsset('sliderHandle', {
anchorX: 0.5,
anchorY: 0.5
}));
self.minX = -380;
self.maxX = 380;
self.isDragging = false;
self.down = function (x, y, obj) {
self.isDragging = true;
self.updateHandle(x);
};
self.up = function (x, y, obj) {
self.isDragging = false;
};
self.updateHandle = function (x) {
var localX = x - self.x;
localX = Math.max(self.minX, Math.min(self.maxX, localX));
sliderHandle.x = localX;
};
self.getSliderValue = function () {
return sliderHandle.x / 380;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000011
});
/****
* Game Code
****/
// Game state management
var gameState = 'menu'; // 'menu', 'settings', 'playing', 'airplanes'
var sensitivity = storage.sensitivity || 1.0;
var selectedAirplane = storage.selectedAirplane || 'classic';
// Menu elements
var titleText = new Text2('SPACE DODGER', {
size: 120,
fill: 0x00aaff
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 600;
game.addChild(titleText);
var startButton = game.addChild(new StartButton());
startButton.x = 2048 / 2;
startButton.y = 1200;
var settingsButton = game.addChild(new SettingsButton());
settingsButton.x = 2048 / 2;
settingsButton.y = 1400;
var airplaneButton = game.addChild(new MenuButton(0x44aa44));
airplaneButton.x = 2048 / 2;
airplaneButton.y = 1600;
// Settings menu elements (initially hidden)
var settingsTitle = new Text2('AJUSTAR SENSIBILIDAD', {
size: 80,
fill: 0xFFFFFF
});
settingsTitle.anchor.set(0.5, 0.5);
settingsTitle.x = 2048 / 2;
settingsTitle.y = 800;
settingsTitle.visible = false;
game.addChild(settingsTitle);
var sensitivitySlider = game.addChild(new SensitivitySlider());
sensitivitySlider.x = 2048 / 2;
sensitivitySlider.y = 1200;
sensitivitySlider.visible = false;
sensitivitySlider.setSensitivity(sensitivity);
var sensValueText = new Text2('Sensibilidad: ' + Math.round(sensitivity * 100) + '%', {
size: 60,
fill: 0xFFFFFF
});
sensValueText.anchor.set(0.5, 0.5);
sensValueText.x = 2048 / 2;
sensValueText.y = 1350;
sensValueText.visible = false;
game.addChild(sensValueText);
var backButton = game.addChild(new BackButton());
backButton.x = 2048 / 2;
backButton.y = 1500;
backButton.visible = false;
// Airplane selection menu elements (initially hidden)
var airplaneTitle = new Text2('ELEGIR AVIÓN', {
size: 80,
fill: 0xFFFFFF
});
airplaneTitle.anchor.set(0.5, 0.5);
airplaneTitle.x = 2048 / 2;
airplaneTitle.y = 600;
airplaneTitle.visible = false;
game.addChild(airplaneTitle);
var airplane1Button = game.addChild(new MenuButton(0x4444aa));
airplane1Button.x = 2048 / 2;
airplane1Button.y = 1000;
airplane1Button.visible = false;
var airplane2Button = game.addChild(new MenuButton(0xaa4444));
airplane2Button.x = 2048 / 2;
airplane2Button.y = 1200;
airplane2Button.visible = false;
var airplane3Button = game.addChild(new MenuButton(0x44aa44));
airplane3Button.x = 2048 / 2;
airplane3Button.y = 1400;
airplane3Button.visible = false;
var airplaneBackButton = game.addChild(new BackButton());
airplaneBackButton.x = 2048 / 2;
airplaneBackButton.y = 1600;
airplaneBackButton.visible = false;
// Decorative elements
var stars = [];
for (var i = 0; i < 50; i++) {
var star = game.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5
}));
star.x = Math.random() * 2048;
star.y = Math.random() * 2732;
star.alpha = Math.random() * 0.8 + 0.2;
stars.push(star);
}
var planet1 = game.addChild(LK.getAsset('planet', {
anchorX: 0.5,
anchorY: 0.5
}));
planet1.x = 200;
planet1.y = 300;
planet1.alpha = 0.6;
planet1.tint = 0x8888ff;
var planet2 = game.addChild(LK.getAsset('planet', {
anchorX: 0.5,
anchorY: 0.5
}));
planet2.x = 1800;
planet2.y = 2400;
planet2.alpha = 0.4;
planet2.tint = 0xff8888;
planet2.scaleX = 0.7;
planet2.scaleY = 0.7;
// Game elements (initially hidden)
var spaceship;
var obstacles = [];
var coins = [];
var coinSpawnTimer = 0;
var coinSpawnRate = 180;
var totalCoins = storage.totalCoins || 0;
var obstacleSpawnTimer = 0;
var obstacleSpawnRate = 90;
var gameSpeed = 1;
var spaceshipSpeed = 1;
var survivalTime = 0;
var difficultyTimer = 0;
var lastScoreCheck = 0;
var speedIncreaseTimer = 0;
var slider;
// GUI elements (created but initially hidden)
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.visible = false;
LK.gui.top.addChild(scoreTxt);
var timeTxt = new Text2('Time: 0s', {
size: 60,
fill: 0xFFFFFF
});
timeTxt.anchor.set(1, 0);
timeTxt.visible = false;
LK.gui.topRight.addChild(timeTxt);
timeTxt.x = -20;
timeTxt.y = 100;
var coinsTxt = new Text2('Coins: ' + totalCoins, {
size: 50,
fill: 0xffd700
});
coinsTxt.anchor.set(0, 0);
coinsTxt.visible = false;
LK.gui.topLeft.addChild(coinsTxt);
coinsTxt.x = 120;
coinsTxt.y = 20;
game.move = function (x, y, obj) {
if (gameState === 'playing' && slider && slider.isDragging) {
slider.updateHandle(x);
var sliderValue = slider.getSliderValue();
spaceship.x = 2048 / 2 + sliderValue * 800 * spaceshipSpeed * sensitivity;
spaceship.x = Math.max(100, Math.min(1948, spaceship.x));
} else if (gameState === 'settings' && sensitivitySlider.isDragging) {
sensitivitySlider.updateHandle(x);
sensitivity = sensitivitySlider.getSensitivity();
sensValueText.setText('Sensibilidad: ' + Math.round(sensitivity * 100) + '%');
storage.sensitivity = sensitivity;
}
};
// Button handlers
startButton.up = function (x, y, obj) {
tween(startButton.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
startGame();
};
settingsButton.up = function (x, y, obj) {
tween(settingsButton.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
showSettings();
};
backButton.up = function (x, y, obj) {
tween(backButton.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
showMenu();
};
airplaneButton.up = function (x, y, obj) {
tween(airplaneButton.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
showAirplaneSelection();
};
airplane1Button.up = function (x, y, obj) {
tween(airplane1Button.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
selectedAirplane = 'classic';
storage.selectedAirplane = selectedAirplane;
showMenu();
};
airplane2Button.up = function (x, y, obj) {
tween(airplane2Button.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
selectedAirplane = 'fast';
storage.selectedAirplane = selectedAirplane;
showMenu();
};
airplane3Button.up = function (x, y, obj) {
tween(airplane3Button.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
selectedAirplane = 'robust';
storage.selectedAirplane = selectedAirplane;
showMenu();
};
airplaneBackButton.up = function (x, y, obj) {
tween(airplaneBackButton.scale, {
x: 1.0,
y: 1.0
}, {
duration: 200
});
showMenu();
};
function startGame() {
gameState = 'playing';
// Hide menu elements
titleText.visible = false;
startButton.visible = false;
settingsButton.visible = false;
airplaneButton.visible = false;
// Show game elements
spaceship = game.addChild(new Spaceship());
spaceship.x = 2048 / 2;
spaceship.y = 2000;
slider = game.addChild(new TouchSlider());
slider.x = 2048 / 2;
slider.y = 2600;
scoreTxt.visible = true;
timeTxt.visible = true;
// Reset game variables
obstacles = [];
coins = [];
coinSpawnTimer = 0;
obstacleSpawnTimer = 0;
obstacleSpawnRate = 90;
coinSpawnRate = 180;
gameSpeed = 1;
spaceshipSpeed = 1;
survivalTime = 0;
difficultyTimer = 0;
speedIncreaseTimer = 0;
lastScoreCheck = 0;
LK.setScore(0);
scoreTxt.setText('0');
timeTxt.setText('Time: 0s');
coinsTxt.visible = true;
coinsTxt.setText('Coins: ' + totalCoins);
}
function showSettings() {
gameState = 'settings';
// Hide menu elements
titleText.visible = false;
startButton.visible = false;
settingsButton.visible = false;
airplaneButton.visible = false;
coinsTxt.visible = false;
// Show settings elements
settingsTitle.visible = true;
sensitivitySlider.visible = true;
sensValueText.visible = true;
backButton.visible = true;
}
function showAirplaneSelection() {
gameState = 'airplanes';
// Hide menu elements
titleText.visible = false;
startButton.visible = false;
settingsButton.visible = false;
airplaneButton.visible = false;
coinsTxt.visible = false;
// Show airplane selection elements
airplaneTitle.visible = true;
airplane1Button.visible = true;
airplane2Button.visible = true;
airplane3Button.visible = true;
airplaneBackButton.visible = true;
}
function showMenu() {
gameState = 'menu';
// Hide settings elements
settingsTitle.visible = false;
sensitivitySlider.visible = false;
sensValueText.visible = false;
backButton.visible = false;
// Hide airplane selection elements
airplaneTitle.visible = false;
airplane1Button.visible = false;
airplane2Button.visible = false;
airplane3Button.visible = false;
airplaneBackButton.visible = false;
// Hide game elements if they exist
if (spaceship) {
spaceship.destroy();
spaceship = null;
}
if (slider) {
slider.destroy();
slider = null;
}
scoreTxt.visible = false;
timeTxt.visible = false;
coinsTxt.visible = false;
// Clear obstacles
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].destroy();
}
obstacles = [];
// Clear coins
for (var i = 0; i < coins.length; i++) {
coins[i].destroy();
}
coins = [];
// Show menu elements
titleText.visible = true;
startButton.visible = true;
settingsButton.visible = true;
airplaneButton.visible = true;
}
game.update = function () {
// Animate stars
for (var s = 0; s < stars.length; s++) {
stars[s].alpha = Math.sin(LK.ticks * 0.02 + s) * 0.3 + 0.5;
}
// Rotate planets slowly
planet1.rotation += 0.005;
planet2.rotation -= 0.003;
// Only run game logic during gameplay
if (gameState !== 'playing' || !spaceship) {
return;
}
survivalTime++;
difficultyTimer++;
speedIncreaseTimer++;
if (survivalTime % 60 === 0) {
var seconds = Math.floor(survivalTime / 60);
timeTxt.setText('Time: ' + seconds + 's');
}
// Every 10 seconds (600 ticks), increase both airplane and obstacle speeds
if (speedIncreaseTimer >= 600) {
speedIncreaseTimer = 0;
gameSpeed *= 1.1; // Increase falling object speed by 10%
spaceshipSpeed *= 1.1; // Increase airplane speed by 10%
}
// Every 15 seconds (900 ticks), increase obstacle speed by 5%
if (difficultyTimer >= 900) {
difficultyTimer = 0;
gameSpeed *= 1.05;
obstacleSpawnRate = Math.max(30, obstacleSpawnRate - 5);
}
// Every 50 points, increase spaceship speed slightly
var currentScore = LK.getScore();
if (Math.floor(currentScore / 50) > Math.floor(lastScoreCheck / 50)) {
spaceshipSpeed += 0.1;
}
lastScoreCheck = currentScore;
obstacleSpawnTimer++;
if (obstacleSpawnTimer >= obstacleSpawnRate) {
obstacleSpawnTimer = 0;
var obstacle;
if (Math.random() < 0.7) {
obstacle = new Meteorite();
} else {
obstacle = new Debris();
}
obstacle.x = Math.random() * 1800 + 124;
obstacle.y = -100;
obstacle.speed *= gameSpeed;
obstacle.lastY = obstacle.y;
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Spawn coins
coinSpawnTimer++;
if (coinSpawnTimer >= coinSpawnRate) {
coinSpawnTimer = 0;
var coin = new Coin();
coin.x = Math.random() * 1800 + 124;
coin.y = -100;
coin.speed *= gameSpeed;
coin.lastY = coin.y;
coins.push(coin);
game.addChild(coin);
}
// Update and check coin collection
for (var c = coins.length - 1; c >= 0; c--) {
var coin = coins[c];
// Remove coins that go off screen
if (coin.y > 2800) {
coin.destroy();
coins.splice(c, 1);
continue;
}
// Check coin collection with spaceship
var dx = spaceship.x - coin.x;
var dy = spaceship.y - coin.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var collectionDistance = 80; // Generous collection radius
if (distance < collectionDistance) {
// Collect coin
totalCoins++;
storage.totalCoins = totalCoins;
coinsTxt.setText('Coins: ' + totalCoins);
// Add coin collection animation
tween(coin, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
coin.destroy();
}
});
coins.splice(c, 1);
continue;
}
coin.lastY = coin.y;
}
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
if (obstacle.lastY < 2800 && obstacle.y >= 2800) {
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
}
if (obstacle.y > 2800) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Only lose if spaceship intersects with meteorites or debris with more precise collision
if (obstacle instanceof Meteorite || obstacle instanceof Debris) {
// Calculate distance between centers
var dx = spaceship.x - obstacle.x;
var dy = spaceship.y - obstacle.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Use smaller collision radius for more precise collision (about 60% of original size)
var spaceshipRadius = spaceship.width * 0.6 / 2;
var obstacleRadius = obstacle.width * 0.6 / 2;
var collisionDistance = spaceshipRadius + obstacleRadius;
if (distance < collisionDistance) {
LK.getSound('destroy').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
showMenu();
return;
}
}
obstacle.lastY = obstacle.y;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -6,20 +6,14 @@
/****
* Classes
****/
-var BackButton = Container.expand(function (text) {
+var BackButton = Container.expand(function () {
var self = Container.call(this);
var buttonBg = self.attachAsset('backButton', {
anchorX: 0.5,
anchorY: 0.5
});
- var buttonText = new Text2(text, {
- size: 40,
- fill: 0xFFFFFF
- });
- buttonText.anchor.set(0.5, 0.5);
- self.addChild(buttonText);
self.down = function (x, y, obj) {
tween(self.scale, {
x: 0.9,
y: 0.9
@@ -66,21 +60,15 @@
self.y += self.speed;
};
return self;
});
-var MenuButton = Container.expand(function (text, color) {
+var MenuButton = Container.expand(function (color) {
var self = Container.call(this);
var buttonBg = self.attachAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5
});
if (color) buttonBg.tint = color;
- var buttonText = new Text2(text, {
- size: 60,
- fill: 0xFFFFFF
- });
- buttonText.anchor.set(0.5, 0.5);
- self.addChild(buttonText);
self.down = function (x, y, obj) {
tween(self.scale, {
x: 0.9,
y: 0.9
@@ -143,20 +131,14 @@
sliderHandle.x = value * 560 - 280;
};
return self;
});
-var SettingsButton = Container.expand(function (text) {
+var SettingsButton = Container.expand(function () {
var self = Container.call(this);
var buttonBg = self.attachAsset('settingsButton', {
anchorX: 0.5,
anchorY: 0.5
});
- var buttonText = new Text2(text, {
- size: 50,
- fill: 0xFFFFFF
- });
- buttonText.anchor.set(0.5, 0.5);
- self.addChild(buttonText);
self.down = function (x, y, obj) {
tween(self.scale, {
x: 0.9,
y: 0.9
@@ -181,8 +163,32 @@
anchorY: 0.5
});
return self;
});
+var StartButton = Container.expand(function () {
+ var self = Container.call(this);
+ var buttonBg = self.attachAsset('startButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.down = function (x, y, obj) {
+ tween(self.scale, {
+ x: 0.9,
+ y: 0.9
+ }, {
+ duration: 200
+ });
+ };
+ self.up = function (x, y, obj) {
+ tween(self.scale, {
+ x: 1.0,
+ y: 1.0
+ }, {
+ duration: 200
+ });
+ };
+ return self;
+});
var TouchSlider = Container.expand(function () {
var self = Container.call(this);
var sliderBar = self.attachAsset('sliderBar', {
anchorX: 0.5,
@@ -235,15 +241,15 @@
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 600;
game.addChild(titleText);
-var startButton = game.addChild(new MenuButton('INICIAR PARTIDA', 0x4444aa));
+var startButton = game.addChild(new StartButton());
startButton.x = 2048 / 2;
startButton.y = 1200;
-var settingsButton = game.addChild(new SettingsButton('SENSIBILIDAD'));
+var settingsButton = game.addChild(new SettingsButton());
settingsButton.x = 2048 / 2;
settingsButton.y = 1400;
-var airplaneButton = game.addChild(new MenuButton('ELEGIR AVIÓN', 0x44aa44));
+var airplaneButton = game.addChild(new MenuButton(0x44aa44));
airplaneButton.x = 2048 / 2;
airplaneButton.y = 1600;
// Settings menu elements (initially hidden)
var settingsTitle = new Text2('AJUSTAR SENSIBILIDAD', {
@@ -268,9 +274,9 @@
sensValueText.x = 2048 / 2;
sensValueText.y = 1350;
sensValueText.visible = false;
game.addChild(sensValueText);
-var backButton = game.addChild(new BackButton('VOLVER'));
+var backButton = game.addChild(new BackButton());
backButton.x = 2048 / 2;
backButton.y = 1500;
backButton.visible = false;
// Airplane selection menu elements (initially hidden)
@@ -282,21 +288,21 @@
airplaneTitle.x = 2048 / 2;
airplaneTitle.y = 600;
airplaneTitle.visible = false;
game.addChild(airplaneTitle);
-var airplane1Button = game.addChild(new MenuButton('AVIÓN CLÁSICO', 0x4444aa));
+var airplane1Button = game.addChild(new MenuButton(0x4444aa));
airplane1Button.x = 2048 / 2;
airplane1Button.y = 1000;
airplane1Button.visible = false;
-var airplane2Button = game.addChild(new MenuButton('AVIÓN RÁPIDO', 0xaa4444));
+var airplane2Button = game.addChild(new MenuButton(0xaa4444));
airplane2Button.x = 2048 / 2;
airplane2Button.y = 1200;
airplane2Button.visible = false;
-var airplane3Button = game.addChild(new MenuButton('AVIÓN ROBUSTO', 0x44aa44));
+var airplane3Button = game.addChild(new MenuButton(0x44aa44));
airplane3Button.x = 2048 / 2;
airplane3Button.y = 1400;
airplane3Button.visible = false;
-var airplaneBackButton = game.addChild(new BackButton('VOLVER'));
+var airplaneBackButton = game.addChild(new BackButton());
airplaneBackButton.x = 2048 / 2;
airplaneBackButton.y = 1600;
airplaneBackButton.visible = false;
// Decorative elements