Commit 2d0a083d authored by Pablo R. Mier's avatar Pablo R. Mier

fix bullet collision bug

parent 4e59794f
......@@ -121,16 +121,18 @@ invadersApp.Game.prototype = {
// Detect collisions with the wall and with the bullets
this.game.physics.arcade.collide(this.wall, this.objects.invaders);
this.game.physics.arcade.overlap(this.player.bullets, this.objects.invaders, function (bullet, invader) {
bullet.kill();
var living = that.objects.invaders.countLiving();
if (living > MIN_INVADERS) {
invader.destroy();
that.updateCounter();
}
if (living == MIN_INVADERS + 1) {
that.objects.invaders.forEachAlive(function (invader) {
invader.drawShield(BLUE);
}, that);
if (bullet.alive) {
bullet.kill();
var living = that.objects.invaders.countLiving();
if (living > MIN_INVADERS) {
invader.destroy();
that.updateCounter();
}
if (living == MIN_INVADERS + 1) {
that.objects.invaders.forEachAlive(function (invader) {
invader.drawShield(BLUE);
}, that);
}
}
}, null, this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment