Closed saw79 closed 4 years ago
Can you post what you're seeing that's breaking as a result? I'm having trouble figuring out the problem from your report.
So it's possible I'm just misunderstanding how to use the library. But I maintain a camera Rectangle that I use to pan/zoom around the world. I update my view with gfx.set_view
.
Most of my input is the user clicking around the world with the mouse. So I use gfx.screen_to_camera
, but it always returns the coordinates relative to the screen no matter where the camera position is. I'll translate the view around as much as I want, but gfx.screen_to_camera
always returns (0, 0) for example if I'm always clicking in the top left. In fact, I don't think screen_to_camera
does anything at all when there is no scale change.
Thanks for being so active and responsive, I think this library is great!
Oh! Yes, the screen_to_camera
function should 100% take into account the current view. Thanks for the report.
Can you check out #648 and see if it fixes your issue?
Cool I think it works!
Title pretty much says it all I think. Looking at the source, it seems like the screen_to_camera function is based off the calculate_viewport function, which in theory is fine: it subtracts off the viewport's topleft coordinate. However the calculate viewport function always returns a Rectangle that is solely a function of its size - its top left is always something like size/2:
line 516:
Rectangle::new((window.size() - size) / 2.0, size)
I think either the calculate_viewport function needs to return the camera translation or a different "viewport" like object needs to be used?