Jump to content

What's the opposite of this.game.add.existing()


Noaml1
 Share

Recommended Posts

So i'm at a hackathon (btw quick responses appreciated because of this fact (´・ω・`) )
and my friend and i are dealing with a players die and respawn often. 
we know that when we want to add a sprite to the game from within a class that extends Phaser.Sprite we have to run the code:

 super(this.game, x, y, ResKeys.player2Sprit); this.game.add.existing(this); //<-----this is the line im referring to

so we want to know if theres an opposite to this.game.add.existing where we can remove the sprite from game existence without killing the class, put it back into that state of limbo between the super() and add() calls.

Link to comment
Share on other sites

If you assign the created object (in that case "the class that extends the Phaser.sprite") to a var and then add the var to the game you can then easily kill it by calling .kill() since the var will be a sprite.

Then you can use .revive() if you want it to keep the same position it where when it died.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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