Closed ghost closed 9 years ago
Idea: Create (or find if SFML has it) a function that translates mouse coordinates into coordinates relative to the size of the window.
Update: Doing that didn't help. Need ideas.
these function should work right? Their purpose is exactly converting window coordinates to world coordinates.
I tried using them, but it didnt work for some reason. The view stretching just doesnt get converted.
First the view has to be set (setView) and then you can use those functions.
getPosition and mapPixelToCoords use the current view.
I think it's just an usage problem.
The UI buttons isnt the only thing affected by it. The stats info (part of the HUD) also depends on view to screen coordinate conversion and suffers from the same bug.
I just figured out something. Have you tried this:
sf::Vector2i pixelPos = sf::Mouse::getPosition(_win);
sf::Vector2f worldPos = UIScene.mapPixelToCoords(pixelPos);
Maybe using the render target to convert the coordinates helps.
That's what I do to get the screen coordinate equivalent.
On Wed, Jan 14, 2015 at 5:28 PM, Sherushe notifications@github.com wrote:
I just figured out something. Have you tried this:
sf::Vector2i pixelPos = sf::Mouse::getPosition(_win); sf::Vector2f worldPos = UIScene.mapPixelToCoords(pixelPos);
Maybe using the render target to convert the coordinates helps.
— Reply to this email directly or view it on GitHub https://github.com/Sherushe/tanks/issues/53#issuecomment-70005303.
Yeah, well, I just tested a couple of possibilities and this seems to work:
sf::Vector2i win_pos = sf::Mouse::getPosition(*_win);
Vec2f pos = _win->mapPixelToCoords(win_pos);
I guess it's normal because the render_target doesn't contain the window's size.
Ok I will check it out.
On Wed, Jan 14, 2015 at 7:12 PM, Sherushe notifications@github.com wrote:
Yeah, well, I just tested a couple of possibilities and this seems to work:
sf::Vector2i win_pos = sf::Mouse::getPosition(*_win); Vec2f pos = _win->mapPixelToCoords(win_pos);
I guess it's normal because the render_target doesn't contain the window's size.
— Reply to this email directly or view it on GitHub https://github.com/Sherushe/tanks/issues/53#issuecomment-70018575.
Don't see mismatching anymore. This is pretty much solved.
https://github.com/Sherushe/tanks/issues/52