mirror of
https://github.com/wassname/phaser.git
synced 2026-08-14 12:40:17 +08:00
Sprite.exists now toggles the Body as well. Sprite.exists = false will remove an active Body from the World.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user