Skip to content

Commit e8b08cb

Browse files
committed
Merge pull request phaserjs#581 from dreadhorse/destroy
Add destroy methods to Ninja Body, AABB and Circle
2 parents b9ac0d5 + e3480ff commit e8b08cb

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

src/physics/ninja/AABB.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,16 @@ Phaser.Physics.Ninja.AABB.prototype = {
10021002

10031003
return Phaser.Physics.Ninja.AABB.COL_NONE;
10041004

1005+
},
1006+
1007+
/**
1008+
* Destroys this AABB's reference to Body and System
1009+
*
1010+
* @method Phaser.Physics.Ninja.AABB#destroy
1011+
*/
1012+
destroy: function() {
1013+
this.body = null;
1014+
this.system = null;
10051015
}
10061016

10071017
}

src/physics/ninja/Body.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,23 @@ Phaser.Physics.Ninja.Body.prototype = {
417417
*/
418418
deltaY: function () {
419419
return this.shape.pos.y - this.shape.oldpos.y;
420-
}
420+
},
421421

422+
/**
423+
* Destroys this body's reference to the sprite and system, and destroys its shape.
424+
*
425+
* @method Phaser.Physics.Ninja.Body#destroy
426+
*/
427+
destroy: function() {
428+
this.sprite = null;
429+
this.system = null;
430+
this.aabb = null;
431+
this.tile = null;
432+
this.circle = null;
433+
434+
this.shape.destroy();
435+
this.shape = null;
436+
}
422437
};
423438

424439
/**

src/physics/ninja/Circle.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,16 @@ Phaser.Physics.Ninja.Circle.prototype = {
26062606
}
26072607

26082608
return Phaser.Physics.Ninja.Circle.COL_NONE;
2609+
},
2610+
2611+
/**
2612+
* Destroys this Circle's reference to Body and System
2613+
*
2614+
* @method Phaser.Physics.Ninja.Circle#destroy
2615+
*/
2616+
destroy: function() {
2617+
this.body = null;
2618+
this.system = null;
26092619
}
26102620

26112621
}

0 commit comments

Comments
 (0)