From 8bbe6fc329759d77afcace75af5fa5abf9efefc2 Mon Sep 17 00:00:00 2001 From: Michael Stanton Date: Tue, 18 Nov 2014 07:39:21 +0100 Subject: [PATCH] die on enemy touch. --- .../boilerplate-master/js/entities/entities.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/melonjs-tutorial/boilerplate-master/js/entities/entities.js b/melonjs-tutorial/boilerplate-master/js/entities/entities.js index e5b2a0d..f69c5f6 100755 --- a/melonjs-tutorial/boilerplate-master/js/entities/entities.js +++ b/melonjs-tutorial/boilerplate-master/js/entities/entities.js @@ -10,6 +10,10 @@ game.PlayerEntity = me.Entity.extend({ }, update: function(dt) { + if (this.alive === false) { + return false; + } + if (me.input.isKeyPressed("left")) { // flip the sprite. this.flipX(true); @@ -67,7 +71,9 @@ game.PlayerEntity = me.Entity.extend({ game.data.score += 30; } else { // Let's flicker in case we touched an enemy - this.renderable.flicker(true); + // this.renderable.flicker(true); + // Naw, let's just die. + this.die(); } } else if (response.b.body.collisionType == me.collision.types.ACTION_OBJECT) { // b is a LevelEntity. Indicate our new respawn point.