Skip to content

Commit 3c564a3

Browse files
committed
The P2 World constructor wouldn't let you use your own config unless you specified both the gravity *and* broadphase. Now allows one or both (thanks @englercj phaserjs#1412)
1 parent 93e0d2f commit 3c564a3

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Version 2.2.2 - "Alkindar" - in development
7676
### Updates
7777

7878
* TypeScript definitions fixes and updates (thanks @clark-stevenson)
79+
* DOM.visualBounds now includes scroll bars (#1429)
80+
* The new fixed time-step code has been more carefully linked to Pixi transform updates. This should finally put a stop to the tunneling issues that were being reported.
7981

8082
### Bug Fixes
8183

@@ -94,6 +96,7 @@ Android browser does not support Full Screen.
9496
* TilemapParser now checks for image collections, avoiding crashes. These would arise with maps exported from the new release of Tiled (thanks @paul-reilly #1440)
9597
* Group.replace could still access `newChild.parent` after it was set to `undefined`. This unifies the approach (thanks @pnstickney #1410 #1417)
9698
* P2.postBroadphaserHandler updated to avoid skipping final 2 pairs.
99+
* The P2 World constructor wouldn't let you use your own config unless you specified both the gravity *and* broadphase. Now allows one or both (thanks @englercj #1412)
97100

98101
For details about changes made in previous versions of Phaser see the full Change Log at https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md
99102

src/physics/p2/World.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,22 @@ Phaser.Physics.P2 = function (game, config) {
2424
*/
2525
this.game = game;
2626

27-
if (typeof config === 'undefined' || !config.hasOwnProperty('gravity') || !config.hasOwnProperty('broadphase'))
27+
if (typeof config === 'undefined')
2828
{
2929
config = { gravity: [0, 0], broadphase: new p2.SAPBroadphase() };
3030
}
31+
else
32+
{
33+
if (!config.hasOwnProperty('gravity')
34+
{
35+
config.gravity: [0, 0];
36+
}
37+
38+
if (!config.hasOwnProperty('broadphase')
39+
{
40+
config.broadphase: new p2.SAPBroadphase();
41+
}
42+
}
3143

3244
/**
3345
* @property {object} config - The p2 World configuration object.

0 commit comments

Comments
 (0)