rtlehr Posted December 19, 2014 Report Share Posted December 19, 2014 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 belowGame.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 Quote Link to comment Share on other sites More sharing options...
rich Posted December 19, 2014 Report Share Posted December 19, 2014 Look at the 3rd parameter of reset: http://docs.phaser.io/Phaser.Sprite.html#reset Quote Link to comment Share on other sites More sharing options...
rtlehr Posted December 19, 2014 Author Report Share Posted December 19, 2014 Oh.... I was looking at the "reset" under "Phaser.Physics.P2.Body" Just saved a line of code... Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.