Sprite.exists now toggles the Body as well. Sprite.exists = false will remove an active Body from the World.

This commit is contained in:
photonstorm
2014-02-13 09:55:46 +00:00
parent b85f40df12
commit 312ec462bc
3 changed files with 70 additions and 8 deletions
+28
View File
@@ -309,6 +309,34 @@ Phaser.Physics.Body.prototype = {
},
/**
* Adds this physics body to the world.
*
* @method Phaser.Physics.Body#addToWorld
*/
addToWorld: function () {
if (this.data.world !== this.game.physics)
{
this.game.physics.addBody(this.data);
}
},
/**
* Removes this physics body from the world.
*
* @method Phaser.Physics.Body#removeFromWorld
*/
removeFromWorld: function () {
if (this.data.world === this.game.physics)
{
this.game.physics.removeBody(this.data);
}
},
/**
* Destroys this Body and all references it holds to other objects.
*