Skip to content

Commit b89cdd5

Browse files
committed
check for existence of sprite on body destroy
1 parent 36c0645 commit b89cdd5

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/physics/p2/Body.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ Phaser.Physics.P2.Body.prototype = {
753753
}
754754
}
755755
}
756-
756+
757757
if (this.data.world !== this.game.physics.p2.world)
758758
{
759759
this.game.physics.p2.addBody(this);
@@ -797,8 +797,11 @@ Phaser.Physics.P2.Body.prototype = {
797797
}
798798

799799
this.debugBody = null;
800-
this.sprite.body = null;
801-
this.sprite = null;
800+
801+
if (this.sprite) {
802+
this.sprite.body = null;
803+
this.sprite = null;
804+
}
802805

803806
},
804807

@@ -1032,9 +1035,9 @@ Phaser.Physics.P2.Body.prototype = {
10321035
removeShape: function (shape) {
10331036

10341037
var result = this.data.removeShape(shape);
1035-
1038+
10361039
this.shapeChanged();
1037-
1040+
10381041
return result;
10391042
},
10401043

0 commit comments

Comments
 (0)