P2.World.clear will now clear out the World.walls property, resetting all of the wall bounds to null. This allows the walls to be re-created accurately when the P2 World is reset, which happens on a State change or restart (thanks @ewpolly1 @codermua #2574)

This commit is contained in:
photonstorm 2016-07-08 13:02:58 +01:00
parent 521a6c9dbb
commit 61ce14f332
2 changed files with 10 additions and 6 deletions

View file

@ -355,7 +355,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
* Phaser.Cache.getPixiBaseTexture has now been removed, as the Pixi Cache isn't used internally anywhere any longer.
* The second argument to Phaser.Cache.removeImage has been renamed from `removeFromPixi` to `destroyBaseTexture`, as that is fundamentally what the argument always did.
* AnimationManager.refreshFrame has been removed as it never actually did anything internally.
* Sound.stop will check to see if `gainNode` exists before trying to disconnect from it.
* Sound.stop will check to see if `gainNode` exists before trying to disconnect from it (#2597)
### Bug Fixes
@ -364,6 +364,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
* Animation.setFrame wouldn't work correctly if the `useLocalFrameIndex` argument was true, and the frame ID was a number (thanks @uboot #2571)
* Polygon.contains would only work with non-flattened Polygon objects. It now works with both flat and non-flat Polygons.
* Graphics objects enabled for input would fail to do anything if a Phaser Polygon was given to the Graphics object (which it was in nearly all cases), as it wouldn't detect input correctly with flattened polygons (thanks @symbiane #2591)
* P2.World.clear will now clear out the World.walls property, resetting all of the wall bounds to `null`. This allows the walls to be re-created accurately when the P2 World is reset, which happens on a State change or restart (thanks @ewpolly1 @codermua #2574)
### Pixi Updates

View file

@ -711,13 +711,13 @@ Phaser.Physics.P2.prototype = {
this.walls[wall] = new p2.Body({ mass: 0, position: [ this.pxmi(x), this.pxmi(y) ], angle: angle });
this.walls[wall].addShape(new p2.Plane());
if (setCollisionGroup)
{
this.walls[wall].shapes[0].collisionGroup = this.boundsCollisionGroup.mask;
}
this.world.addBody(this.walls[wall]);
}
if (setCollisionGroup)
{
this.walls[wall].shapes[0].collisionGroup = this.boundsCollisionGroup.mask;
}
}
else
{
@ -866,6 +866,9 @@ Phaser.Physics.P2.prototype = {
this._toRemove = [];
this.boundsCollidesWith = [];
// Remove the world bounds
this.walls = { left: null, right: null, top: null, bottom: null };
},
/**