jwdevel Posted September 12, 2016 Share Posted September 12, 2016 It seems that Sprite.getBounds returns camera-relative coordinates. The docs say "Returns the bounds of the Sprite as a rectangle. The bounds calculation takes the worldTransform into account" which would indicate to me that they give world coordinates. However, looking at the code a bit, it seems that in a simple game you might have the hierarchy: Stage -> World -> Group -> Sprite And if the camera is at position (100,100), then that means the World's transform is at (-100, -100). Then, when getBounds is called on the sprite, it traverses its parents, accounting for all transforms, and thus the camera's (-100, -100) is included. Is this a bug? At least in the documentation? I can work around it easily enough (add the camera's coords to what getBounds returns), but it made me pull some hair out (: I'm using Phaser 2.4.4 Here's another forum post about the same issue, FYI: Link to comment Share on other sites More sharing options...
Recommended Posts