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

Tile.getCenterX and Tile.getCenterY returns wrong value for scaled layers #3845

Closed
oloflarsson opened this issue Jul 19, 2018 · 3 comments
Closed

Comments

@oloflarsson
Copy link

oloflarsson commented Jul 19, 2018

The following two lines:

Currently look like this:

  • return this.getLeft(camera) + this.width / 2;
  • return this.getTop(camera) + this.height / 2;

But they should probably look something like this:

  • return (this.getLeft(camera) + this.getRight(camera)) / 2;
  • return (this.getTop(camera) + this.getBottom(camera)) / 2;

Or perhaps like this:

What currently happens is that tile.getCenterX() and tile.getCenterY will return correct values when the layer has scale 1, but wrong values for other scales.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@oloflarsson
Copy link
Author

I propose setting these labels: Bug, Priority: Low, and Difficulty: Easy.

This is a code example of how I work around the bug in the game I'm making:

hitCoin (sprite, tile) {
    this.layer.removeTileAt(tile.x, tile.y);
    window.incrementGold();

    const x = (tile.getLeft() + tile.getRight()) / 2;
    const y = (tile.getTop() + tile.getBottom()) / 2;
    const style = PxlColor.GOLD;
    const count = 30;
    const lifespan = 500;
    this.particles.explosion(x, y, style, count, lifespan);
}

@florianvazelle
Copy link
Contributor

I managed to reproduce the issue, and I'm looking for my first open source contribution, so I would like to work on it.

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

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

No branches or pull requests

3 participants