Skip to content

Commit 1a407bc

Browse files
committed
ArcadePhysics.Body.destroy will now only add itself to the World pendingDestroy list if the world property exists. This prevents Cannot read property 'pendingDestroy' of undefined errors if you try to delete a physics body in a callback and then immediately change Scene (which tells the physics work to also delete all bodies)
1 parent bca8d9b commit 1a407bc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/physics/arcade/Body.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,10 @@ var Body = new Class({
13971397
{
13981398
this.enable = false;
13991399

1400-
this.world.pendingDestroy.set(this);
1400+
if (this.world)
1401+
{
1402+
this.world.pendingDestroy.set(this);
1403+
}
14011404
},
14021405

14031406
/**

0 commit comments

Comments
 (0)