SFML community forums
Help => General => Topic started by: phear- on July 17, 2009, 01:10:52 am
-
I'm new to SFML (only about 12 hours in atm haha) and im getting stuck at finding the global mouse coords. I'm in the process of making an RTS and atm im trying to get the map to move around. This is what i'm using right now:
//Direction 1 (Quadrant 1 - North West)
if ((Event.MouseMove.X > 50) && (Event.MouseMove.Y < ((int)App.GetHeight() + 50)))
{
GameView.Move(-1.f * ElapsedTime, -1.f);
}
The Event.MouseMove.X is giving me the mouse position within the view. I've tried a few different methods and still cant seem to find it.
Thanks for any help :)
-
You can get the global mouse coords by using
App.GetInput().GetMouseX()
App.GetInput().GetMouseY()
-
An alternative is sf::RenderWindow::ConvertCoords().
-
Event.MouseMove and App.GetInput().GetMouse*() will both give you mouse coordinates relative to the window.
ConvertCoords will then convert these coordinates to coordinates relative to the "scene" (what you call global coordinates).