Skip to content

Commit b81b268

Browse files
committed
Matter JS bodies now have a destroy method that removes them from the world.
1 parent c6f4a6e commit b81b268

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/physics/matter-js/components/SetBody.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ var SetBody = {
112112
this.body = body;
113113
this.body.gameObject = this;
114114

115+
var _this = this;
116+
117+
this.body.destroy = function ()
118+
{
119+
_this.world.remove(_this.body);
120+
_this.body.gameObject = null;
121+
};
122+
115123
if (addToWorld)
116124
{
117125
this.world.add(this.body);

0 commit comments

Comments
 (0)