diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js index 7e100c84..a4c14556 100644 --- a/src/gameobjects/Sprite.js +++ b/src/gameobjects/Sprite.js @@ -903,9 +903,11 @@ Object.defineProperty(Phaser.Sprite.prototype, "exists", { { // exists = false this._cache[6] = 0; + console.log('exists false'); if (this.body) { + console.log('exists false remove from world'); this.body.removeFromWorld(); } diff --git a/src/physics/Body.js b/src/physics/Body.js index 2e0727ae..b272a274 100644 --- a/src/physics/Body.js +++ b/src/physics/Body.js @@ -532,7 +532,7 @@ Phaser.Physics.Body.prototype = { */ addToWorld: function () { - if (this.data.world !== this.game.physics) + if (this.data.world !== this.game.physics.world) { this.game.physics.addBody(this); } @@ -546,9 +546,9 @@ Phaser.Physics.Body.prototype = { */ removeFromWorld: function () { - if (this.data.world === this.game.physics) + if (this.data.world === this.game.physics.world) { - this.game.physics.removeBody(this.data); + this.game.physics.removeBody(this); } }, diff --git a/src/physics/World.js b/src/physics/World.js index 5b8578e2..427e38c6 100644 --- a/src/physics/World.js +++ b/src/physics/World.js @@ -208,11 +208,15 @@ Phaser.Physics.World.prototype = { if (event.bodyA.id > 1 && event.bodyB.id > 1) { console.log('impactHandler'); + console.log(event); console.log(event.bodyA.parent.sprite.key); - console.log(event.bodyB.parent.sprite.key); - } - event = {}; + if (event.bodyB.parent.sprite.key == 'box') + { + console.log(event.bodyB.parent.sprite.key + ' KILLED'); + event.bodyB.parent.sprite.kill(); + } + } },