mirror of
https://github.com/danbee/invaders
synced 2025-03-04 08:39:08 +00:00
Make aliens movement more organic.
This commit is contained in:
parent
97b39eadf5
commit
15554a106b
@ -39,10 +39,6 @@ function create () {
|
|||||||
bullets.setAll('outOfBoundsKill', true);
|
bullets.setAll('outOfBoundsKill', true);
|
||||||
|
|
||||||
// Initialize aliens
|
// Initialize aliens
|
||||||
aliens = game.add.group();
|
|
||||||
aliens.enableBody = true;
|
|
||||||
aliens.physicsBodyType = Phaser.Physics.ARCADE;
|
|
||||||
|
|
||||||
createAliens();
|
createAliens();
|
||||||
animateAliens();
|
animateAliens();
|
||||||
|
|
||||||
@ -150,7 +146,7 @@ function bulletHitsAlien (bullet, alien) {
|
|||||||
updateScore();
|
updateScore();
|
||||||
|
|
||||||
if (aliens.countLiving() == 0) {
|
if (aliens.countLiving() == 0) {
|
||||||
newWave()
|
newWave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,6 +202,7 @@ function newWave () {
|
|||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
aliens.removeAll();
|
aliens.removeAll();
|
||||||
createAliens();
|
createAliens();
|
||||||
|
animateAliens();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,6 +231,10 @@ function gameOver () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createAliens () {
|
function createAliens () {
|
||||||
|
aliens = game.add.group();
|
||||||
|
aliens.enableBody = true;
|
||||||
|
aliens.physicsBodyType = Phaser.Physics.ARCADE;
|
||||||
|
|
||||||
for (var y = 0; y < 4; y++) {
|
for (var y = 0; y < 4; y++) {
|
||||||
for (var x = 0; x < 10; x++) {
|
for (var x = 0; x < 10; x++) {
|
||||||
var alien = aliens.create(x * 72, y * 48, 'alien');
|
var alien = aliens.create(x * 72, y * 48, 'alien');
|
||||||
@ -244,6 +245,10 @@ function createAliens () {
|
|||||||
|
|
||||||
aliens.x = 64;
|
aliens.x = 64;
|
||||||
aliens.y = 96;
|
aliens.y = 96;
|
||||||
|
|
||||||
|
aliens.forEach(function (alien, i) {
|
||||||
|
game.add.tween(alien).to( { y: alien.body.y + 5 }, 500, Phaser.Easing.Sinusoidal.InOut, true, game.rnd.integerInRange(0, 500), 1000, true);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function animateAliens () {
|
function animateAliens () {
|
||||||
@ -277,7 +282,8 @@ function dropBomb (alien) {
|
|||||||
|
|
||||||
function descend () {
|
function descend () {
|
||||||
if (player.alive) {
|
if (player.alive) {
|
||||||
aliens.y += 8;
|
//aliens.y += 8;
|
||||||
|
game.add.tween(aliens).to( { y: aliens.y + 8 }, 2500, Phaser.Easing.Linear.None, true, 0, 0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user