From 291f8ef14cbf8e294ac472e4c3ec7db017f99882 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Fri, 14 Feb 2014 17:52:59 +0000 Subject: [PATCH] Fixed issue with physics world not being centered if you resized it. --- examples/wip/p25.js | 4 ++-- src/physics/World.js | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/wip/p25.js b/examples/wip/p25.js index 3b98e37a..9cf55a09 100644 --- a/examples/wip/p25.js +++ b/examples/wip/p25.js @@ -62,8 +62,8 @@ function update() { function render() { - // game.debug.renderText('x: ' + box2.body.velocity.x, 32, 32); - // game.debug.renderText('y: ' + box2.body.velocity.y, 32, 64); + game.debug.renderText('x: ' + ship.body.x, 32, 32); + game.debug.renderText('y: ' + ship.body.y, 32, 64); } diff --git a/src/physics/World.js b/src/physics/World.js index 689e8cb7..3b567a70 100644 --- a/src/physics/World.js +++ b/src/physics/World.js @@ -168,11 +168,16 @@ Phaser.Physics.World.prototype.setBounds = function (x, y, width, height, left, { this.removeBody(this.bounds); - for (var i = this.bounds.shapes.length - 1; i >= 0; i--) + var i = this.bounds.shapes.length; + + while (i--) { var shape = this.bounds.shapes[i]; this.bounds.removeShape(shape); } + + this.bounds.position[0] = this.game.math.px2p(cx); + this.bounds.position[1] = this.game.math.px2p(cy); } else {