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

Author Topic: Getting mouse position.  (Read 1079 times)

0 Members and 1 Guest are viewing this topic.

Borek23

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Getting mouse position.
« on: May 07, 2012, 08:38:12 pm »
Hi! I'm looking for my answer for about 2 days and still nothing. How to get mouse position even if in console in SMFL 2?
 That's what i get :


Even if I change mouse position it would still be the same...  There's piece of code :
sf::Vector2i Mousepos;
Mousepos = sf::Mouse::getPosition(myWindow);

sf::Event event;
        if(event.type == sf::Event::MouseMoved)
        {
            cout << "Mouse position " << Mousepos.x << "\t " << Mousepos.y << endl;
        }
 

How can I change these positions ?
Sorry for mistakes...
« Last Edit: May 07, 2012, 08:40:41 pm by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Getting mouse position.
« Reply #1 on: May 07, 2012, 08:42:15 pm »
You shouldn't mix events and real-time inputs. If you caught a MouseMoved event then use the event.mouseMove object, otherwise just use what sf::Mouse::getPosition returned without mixing with events.
Laurent Gomila - SFML developer

Borek23

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Getting mouse position.
« Reply #2 on: May 07, 2012, 09:56:53 pm »
Thanks mate, problem solved  ;)

 

anything