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

World Wrap Using Wrong Coordinates When useBounds is True #1020

Closed
jackrugile opened this issue Jul 15, 2014 · 1 comment
Closed

World Wrap Using Wrong Coordinates When useBounds is True #1020

jackrugile opened this issue Jul 15, 2014 · 1 comment

Comments

@jackrugile
Copy link
Contributor

I am wrapping my hero horizontally, and there seems to be an issue when the world is bigger than the game/camera width.

CodePen Demo Here

The hero spawns in the middle of a 1000 x 500 world in a 500 x 500 game. When the hero leaves the world on the left, all is fine because 0 in the game/camera and 0 in the world are at the same point. However, as you move the hero to the right, you can see when the camera starts following the hero that the _currentBounds show the position in relation to the camera, not the world. This causes an issue when leaving the right side of the world because the numbers do not match up.

So, there are two possible reasons this isn't working, I believe:

  1. The sprite.getBounds() call in World.js is a Pixi specific function, so it is supposed to return the rendering coordinates, not the world coordinates. If that's the case, then a different function should be used in the World.wrap() function to get the bounds.
  2. There is a bug with the Pixi getBounds() function... but I don't think that is the case, as the concept of a world is unique to Phaser, and not part of Pixi.

Please look at the demo and let me know your thoughts. Perhaps some sort of camera offset has to be factored into the world wrap logic somehow. Thanks!

photonstorm added a commit that referenced this issue Jul 15, 2014
…unds correctly, meaning wrapping outside the camera failed (thanks @jackrugile #1020)
@photonstorm
Copy link
Collaborator

This is now fixed. It's not perfect because if you use an offset anchor it doesn't take that into consideration - but at least it actually works properly now.

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