SFML community forums

Help => General => Topic started by: phear- on July 17, 2009, 01:10:52 am

Title: [Newbie Question] Getting global mouse coords
Post 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:

Code: [Select]

//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 :)
Title: [Newbie Question] Getting global mouse coords
Post by: Lynix on July 17, 2009, 01:29:13 am
You can get the global mouse coords by using
Quote
App.GetInput().GetMouseX()
App.GetInput().GetMouseY()
Title: [Newbie Question] Getting global mouse coords
Post by: Nexus on July 17, 2009, 02:17:14 am
An alternative is sf::RenderWindow::ConvertCoords().
Title: [Newbie Question] Getting global mouse coords
Post by: Laurent on July 17, 2009, 08:37:22 am
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).