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

Sprite.body.setSize bug #889

Closed
casensiom opened this issue Jun 8, 2014 · 1 comment
Closed

Sprite.body.setSize bug #889

casensiom opened this issue Jun 8, 2014 · 1 comment

Comments

@casensiom
Copy link

There's a little problem with this method.

if we just create a Sprite and intialize his body with nonzero offsets, the following calls with offset set to zero will be ignored (just the offsets, not the sizes).

    mySprite = game.add.sprite(_x, _y, 'abbaye_texture');
    game.physics.enable(mySprite, Phaser.Physics.ARCADE);
    mySprite.body.setSize(8, 20, 10, 10); // set the body with an offset
    ...
    mySprite.body.setSize(8, 20, 0, 0); // reset the body to the sprite position is ignored

The problem is at the Phaser.Physics.Arcade.Body#setSize method, with the lines:

        offsetX = offsetX || this.offset.x;
        offsetY = offsetY || this.offset.y;

I think it should be something like this:

    if (typeof offsetX === 'undefined') { offsetX = this.offset.x; }
    if (typeof offsetY === 'undefined') { offsetY = this.offset.y; }
photonstorm added a commit that referenced this issue Jun 10, 2014
…d then passed zero values they would be ignored (thanks @casensiom fix #889)
@photonstorm
Copy link
Collaborator

Agreed, thanks. This is fixed in dev.

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