mirror of
https://github.com/photonstorm/phaser
synced 2024-11-16 09:48:18 +00:00
Add destroy methods to Ninja Body, AABB and Circle
The Sprite.destroy() method calls the Body’s destroy() method if a body exists. If using Ninja physics, destroying a Sprite will not work, since the destroy method wasn’t implemented in Ninja’s Body. Also added destroy() methods to Ninja’s AABB and Circle. Tile already have a destroy() method.
This commit is contained in:
parent
b9ac0d565e
commit
e3480ffd3c
3 changed files with 36 additions and 1 deletions
|
@ -1002,6 +1002,16 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
|
||||
return Phaser.Physics.Ninja.AABB.COL_NONE;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this AABB's reference to Body and System
|
||||
*
|
||||
* @method Phaser.Physics.Ninja.AABB#destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
this.body = null;
|
||||
this.system = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -417,8 +417,23 @@ Phaser.Physics.Ninja.Body.prototype = {
|
|||
*/
|
||||
deltaY: function () {
|
||||
return this.shape.pos.y - this.shape.oldpos.y;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this body's reference to the sprite and system, and destroys its shape.
|
||||
*
|
||||
* @method Phaser.Physics.Ninja.Body#destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
this.sprite = null;
|
||||
this.system = null;
|
||||
this.aabb = null;
|
||||
this.tile = null;
|
||||
this.circle = null;
|
||||
|
||||
this.shape.destroy();
|
||||
this.shape = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -2606,6 +2606,16 @@ Phaser.Physics.Ninja.Circle.prototype = {
|
|||
}
|
||||
|
||||
return Phaser.Physics.Ninja.Circle.COL_NONE;
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this Circle's reference to Body and System
|
||||
*
|
||||
* @method Phaser.Physics.Ninja.Circle#destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
this.body = null;
|
||||
this.system = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue