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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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