Jump to content

reset() a sprite resets health to 1


rtlehr
 Share

Recommended Posts

Just found something that I thought was odd because I do not see anything in the docs about this...

 

When I revive a dead sprite using the code below

Game.world.prototype.reviveEnemy = function(reviveMe)    {        //Revive the enemy        reviveMe.revive();                //set the health of the enemy ship        reviveMe.health = 200;        //Move the enemy to the location of the mother ship        reviveMe.reset(this.level.mothership.x, this.level.mothership.y);    };

The health of the sprite gets set back to 1 after the reset function is called.  This stumped me for a little while because the documentation only says that reset "Resets the Body force, velocity (linear and angular) and rotation. Optionally resets damping and mass." Once I did changed things around, see below, everything worked the way I wanted.

Game.world.prototype.reviveEnemy = function(reviveMe)    {        //Revive the enemy        reviveMe.revive();        //Move the enemy to the location of the mother ship        reviveMe.reset(this.level.mothership.x, this.level.mothership.y);        //set the health of the enemy ship        reviveMe.health = 200;    };

I did not know if this was a bug, or if the reset function, resets EVERYTHING for the sprite. If it's the latter then maybe the docs can be updated.  Just a thought.

 

Thanks,

Ross

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...