Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Newbie Question] Getting global mouse coords  (Read 2679 times)

0 Members and 1 Guest are viewing this topic.

phear-

  • Jr. Member
  • **
  • Posts: 64
    • MSN Messenger - LOApokalypse@hotmail.com
    • View Profile
    • http://gtproductions.org
[Newbie Question] Getting global mouse coords
« 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 :)
Eugene Alfonso
GTP | Twitter

Lynix

  • Sr. Member
  • ****
  • Posts: 403
    • View Profile
[Newbie Question] Getting global mouse coords
« Reply #1 on: July 17, 2009, 01:29:13 am »
You can get the global mouse coords by using
Quote
App.GetInput().GetMouseX()
App.GetInput().GetMouseY()

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
[Newbie Question] Getting global mouse coords
« Reply #2 on: July 17, 2009, 02:17:14 am »
An alternative is sf::RenderWindow::ConvertCoords().
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[Newbie Question] Getting global mouse coords
« Reply #3 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).
Laurent Gomila - SFML developer