1 decade ago by dotnetprodev
In the "Introducing HTML5 Game Development" book where it talks about invincibility after a respawn, you can check to make sure that the zombie entity is not colliding with the player; ie: the player will remain invincible until the zombie leaves so you don't continuously get re-killed.
Update the code in player.js:
1: update the "checkAgainst" property to type.B:
type: ig.Entity.TYPE.A,
checkAgainst: ig.Entity.TYPE.B,
2: add a "check" function in your player class:
check: function( other ) {
if( this.invincible ) {
// reset the invincibility timer
this.invincibleTimer.reset();
return;
}
},
Update the code in player.js:
1: update the "checkAgainst" property to type.B:
type: ig.Entity.TYPE.A,
checkAgainst: ig.Entity.TYPE.B,
2: add a "check" function in your player class:
check: function( other ) {
if( this.invincible ) {
// reset the invincibility timer
this.invincibleTimer.reset();
return;
}
},