Skip to content

Commit f6807e2

Browse files
committed
Fixed Body.removeFromWorld
1 parent 7373db6 commit f6807e2

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/gameobjects/Sprite.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,11 @@ Object.defineProperty(Phaser.Sprite.prototype, "exists", {
903903
{
904904
// exists = false
905905
this._cache[6] = 0;
906+
console.log('exists false');
906907

907908
if (this.body)
908909
{
910+
console.log('exists false remove from world');
909911
this.body.removeFromWorld();
910912
}
911913

src/physics/Body.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ Phaser.Physics.Body.prototype = {
532532
*/
533533
addToWorld: function () {
534534

535-
if (this.data.world !== this.game.physics)
535+
if (this.data.world !== this.game.physics.world)
536536
{
537537
this.game.physics.addBody(this);
538538
}
@@ -546,9 +546,9 @@ Phaser.Physics.Body.prototype = {
546546
*/
547547
removeFromWorld: function () {
548548

549-
if (this.data.world === this.game.physics)
549+
if (this.data.world === this.game.physics.world)
550550
{
551-
this.game.physics.removeBody(this.data);
551+
this.game.physics.removeBody(this);
552552
}
553553

554554
},

src/physics/World.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,15 @@ Phaser.Physics.World.prototype = {
208208
if (event.bodyA.id > 1 && event.bodyB.id > 1)
209209
{
210210
console.log('impactHandler');
211+
console.log(event);
211212
console.log(event.bodyA.parent.sprite.key);
212-
console.log(event.bodyB.parent.sprite.key);
213-
}
214213

215-
event = {};
214+
if (event.bodyB.parent.sprite.key == 'box')
215+
{
216+
console.log(event.bodyB.parent.sprite.key + ' KILLED');
217+
event.bodyB.parent.sprite.kill();
218+
}
219+
}
216220

217221
},
218222

0 commit comments

Comments
 (0)