Skip to content

Commit 291f8ef

Browse files
committed
Fixed issue with physics world not being centered if you resized it.
1 parent 1b5837d commit 291f8ef

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

examples/wip/p25.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ function update() {
6262

6363
function render() {
6464

65-
// game.debug.renderText('x: ' + box2.body.velocity.x, 32, 32);
66-
// game.debug.renderText('y: ' + box2.body.velocity.y, 32, 64);
65+
game.debug.renderText('x: ' + ship.body.x, 32, 32);
66+
game.debug.renderText('y: ' + ship.body.y, 32, 64);
6767

6868
}
6969

src/physics/World.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,16 @@ Phaser.Physics.World.prototype.setBounds = function (x, y, width, height, left,
168168
{
169169
this.removeBody(this.bounds);
170170

171-
for (var i = this.bounds.shapes.length - 1; i >= 0; i--)
171+
var i = this.bounds.shapes.length;
172+
173+
while (i--)
172174
{
173175
var shape = this.bounds.shapes[i];
174176
this.bounds.removeShape(shape);
175177
}
178+
179+
this.bounds.position[0] = this.game.math.px2p(cx);
180+
this.bounds.position[1] = this.game.math.px2p(cy);
176181
}
177182
else
178183
{

0 commit comments

Comments
 (0)