diff --git a/README.md b/README.md index f0435d21b..e8398951b 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Bug Fixes * Group enableBody parameter was incorrectly assigned to the debug var (thanks BurnedToast, fix #565) * Fixed Tile callback check in Arcade Physics (fix #562) * Removed the examples build script from the Gruntfile (fix #592) +* The P2 World wouldn't clear down fully on a State change, now properly clears out contacts, resets the bitmask, etc. TODO: diff --git a/src/physics/p2/World.js b/src/physics/p2/World.js index a554f69f4..4dea87ebf 100644 --- a/src/physics/p2/World.js +++ b/src/physics/p2/World.js @@ -659,6 +659,17 @@ Phaser.Physics.P2.prototype = { this.world.clear(); + this.world.off("beginContact", this.beginContactHandler, this); + this.world.off("endContact", this.endContactHandler, this); + + this.collisionGroups = []; + this._toRemove = []; + this.boundsCollidesWith = []; + this._collisionGroupID = 2; + this.postBroadphaseCallback = null; + this.callbackContext = null; + this.impactCallback = null; + }, /** @@ -668,7 +679,7 @@ Phaser.Physics.P2.prototype = { */ destroy: function () { - this.world.clear(); + this.clear(); this.game = null;