Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

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;
}
},

1 decade ago by dotnetprodev

Also, put this in the update function to make sure the player does not try to cheat and use the invincibility to his advantage:

// turn off invincibility if the player moves
if( this.accel.x > 0 && this.invincible ) {
this.invincible = false;
this.currentAnim.alpha = 1;
}
Page 1 of 1
« first « previous next › last »