Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset on "sprite.body" doesn't work. #2430

Closed
Mourtz opened this issue Apr 13, 2016 · 2 comments
Closed

Offset on "sprite.body" doesn't work. #2430

Mourtz opened this issue Apr 13, 2016 · 2 comments

Comments

@Mourtz
Copy link
Contributor

Mourtz commented Apr 13, 2016

Hi,

Noticed while working on a project with Phaser that "P2.Body.offset" doesn't work when the pivot point of the sprite has been changed.

Looking forward to patching this.

Thanks.

Example Code:

function preload() {
    game.load.image('foo', 'foo.png');
    game.load.physics('foo-coll', 'foo.json');
}

function create(){       
    //  Enable p2 physics
    game.physics.startSystem(Phaser.Physics.P2JS);
    game.physics.p2.gravity.y = 0;
    game.physics.p2.restitution = 1;

    var bar = game.add.sprite(game.world.centerX, game.world.centerY, 'foo');
    bar.anchor.setTo(0.5);
    bar.pivot.x = -200;
    bar.pivot.y = 300;

    game.physics.p2.enable(bar, true);
    bar.body.kinematic = true;

    bar.body.clearShapes();
    bar.body.loadPolygon('foo-coll', 'foo');

    bar.body.offset.setTo(this.game.width / 3);
}
@Mourtz Mourtz changed the title Offset on "sprite.body" doesn't work when pivot has been changed. Offset on "sprite.body" doesn't work. Apr 13, 2016
@Mourtz
Copy link
Contributor Author

Mourtz commented Apr 18, 2016

By looking at the code I found out that "P2.Body.offset" is never being used. Apparently, this is a feature request instead of bug fix.

photonstorm added a commit that referenced this issue Apr 18, 2016
…rendering. The values given are normal pixel values, and offset the P2 Body from the center of the Sprite (thanks @Mourtz #2430)
@photonstorm
Copy link
Collaborator

Thanks for submitting this issue. We have fixed this, and the fix has been pushed to the dev branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants