SFML community forums
Help => Window => Topic started by: rpaggi on April 15, 2014, 03:49:00 am
-
Hi,
I have an problem, i start my Window and i get the mouse positions( sf::Mouse::getPosition() ), when i move my view the mouse positions changes too.
Have anyway to keep the mouse positions independent of View movement?
Sorry my bad English, thanks
-
sf::Mouse::getPosition() gives you the position on the mouse on the screen. So it is already independent of any sf::View you might be using. It's even independent of the window position unless your provide a window as an argument to getPosition.
-
I don't know what you mean by "keep the mouse positions independent of View movement" (as G said, they already are independent) but the functions mapPixelToCoords() and mapCoordsToPixel() might be part of the solution.
-
Hello,
Example:
When i used sf::Mouse::getPosition(), it returned the vector 200, 200
After i used an view.move(10, 20), after this i used again sf::Mouse::getPosition() and it returned the vector 210, 230.
I'm using sfml-tmxloader to use Tiled maps, this can affect this?
Thanks
-
Assuming you didn't move the mouse yourself between those calls, that does not sound possible. Can you show us a complete and minimal code example? We must be misunderstanding your explanation somehow.
I can't imagine tiled maps have anything to do with it. Like G said, Mouse::getPosition() only gets the position on your monitor. It has nothing to do with what's being drawn in your window or game world.
-
Sorry guys,
Really works.
Thanks for the help!
-
I have same issue in the past but reading this post I have solved the problem.