Fixed Body.removeFromWorld

This commit is contained in:
photonstorm 2014-02-19 04:05:12 +00:00
parent 7373db6e8c
commit f6807e23c6
3 changed files with 12 additions and 6 deletions

View file

@ -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();
}

View file

@ -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);
}
},

View file

@ -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();
}
}
},