Phaser: Box2D Plugin - renderBody seems to incorrectly render x-direction on camera move

Created on 3 Feb 2017  路  1Comment  路  Source: photonstorm/phaser

It seems that the Box2D debug render body function incorrectly moves the x coordinate when the camera moves.
box2d-renderbody-issue
In this gif, only the camera is moving, the body is completely static.

This forum post suggests the solution is in Box2D, in the renderBody method, changing

    xf.p.x += -body.game.camera.x / world.ptmRatio;
    xf.p.y -= -body.game.camera.y / world.ptmRatio;

to

    xf.p.x -= -body.game.camera.x / world.ptmRatio;
    xf.p.y -= -body.game.camera.y / world.ptmRatio;

Seems to fix things.

Most helpful comment

Wouldn't the fix be better like this:

    xf.p.x += body.game.camera.x / world.ptmRatio;
    xf.p.y += body.game.camera.y / world.ptmRatio;

I think there's no reason for the double minus sign.

>All comments

Wouldn't the fix be better like this:

    xf.p.x += body.game.camera.x / world.ptmRatio;
    xf.p.y += body.game.camera.y / world.ptmRatio;

I think there's no reason for the double minus sign.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samme picture samme  路  4Comments

cncolder picture cncolder  路  4Comments

JoeBerkley picture JoeBerkley  路  3Comments

sercand picture sercand  路  3Comments

HDouss picture HDouss  路  3Comments