Skip to content

Commit 96296c6

Browse files
committed
The P2 World wouldn't clear down fully on a State change, now properly clears out contacts, resets the bitmask, etc.
1 parent 67919af commit 96296c6

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Bug Fixes
6565
* Group enableBody parameter was incorrectly assigned to the debug var (thanks BurnedToast, fix #565)
6666
* Fixed Tile callback check in Arcade Physics (fix #562)
6767
* Removed the examples build script from the Gruntfile (fix #592)
68+
* The P2 World wouldn't clear down fully on a State change, now properly clears out contacts, resets the bitmask, etc.
6869

6970

7071
TODO:

src/physics/p2/World.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,17 @@ Phaser.Physics.P2.prototype = {
659659

660660
this.world.clear();
661661

662+
this.world.off("beginContact", this.beginContactHandler, this);
663+
this.world.off("endContact", this.endContactHandler, this);
664+
665+
this.collisionGroups = [];
666+
this._toRemove = [];
667+
this.boundsCollidesWith = [];
668+
this._collisionGroupID = 2;
669+
this.postBroadphaseCallback = null;
670+
this.callbackContext = null;
671+
this.impactCallback = null;
672+
662673
},
663674

664675
/**
@@ -668,7 +679,7 @@ Phaser.Physics.P2.prototype = {
668679
*/
669680
destroy: function () {
670681

671-
this.world.clear();
682+
this.clear();
672683

673684
this.game = null;
674685

0 commit comments

Comments
 (0)