Skip to content

Commit 628dd1c

Browse files
committed
P2.Body.offset is now used and applied to the Sprite position during rendering. The values given are normal pixel values, and offset the P2 Body from the center of the Sprite (thanks @Mourtz phaserjs#2430)
1 parent a2d145a commit 628dd1c

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
353353
* The Arcade Physics Body has two new properties: `left` and `top`. These are the same as `Body.x` and `Body.y` but allow you to pass the Body to geometry level functions such as Circle.contains.
354354
* World.separate has been optimized to cut down on the number of calls to `intersect` from 3 calls per Game Object collision check, to 2. So if you were colliding 50 sprites it will reduce the call count from 150 to 100 per frame. It also reduces the calls made to `seperateX` and `seperateY` by the same factor.
355355
* Two immovable bodies would never set their overlap data, even if an overlap only check was being made. As this is useful data to have this has been changed. Two immovable bodies will still never separate from each other, but they _will_ have their `overlapX` and `overlapY` properties calculated now.
356+
* P2.Body.offset is now used and applied to the Sprite position during rendering. The values given are normal pixel values, and offset the P2 Body from the center of the Sprite (thanks @Mourtz #2430)
356357

357358
### Updates
358359

src/physics/p2/Body.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,8 @@ Phaser.Physics.P2.Body.prototype = {
851851
*/
852852
postUpdate: function () {
853853

854-
this.sprite.x = this.world.mpxi(this.data.position[0]);
855-
this.sprite.y = this.world.mpxi(this.data.position[1]);
854+
this.sprite.x = this.world.mpxi(this.data.position[0]) + this.offset.x;
855+
this.sprite.y = this.world.mpxi(this.data.position[1]) + this.offset.y;
856856

857857
if (!this.fixedRotation)
858858
{

0 commit comments

Comments
 (0)