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

Author Topic: [SFML 2.0] Getting mouse input/coordinates  (Read 4686 times)

0 Members and 2 Guests are viewing this topic.

imcit

  • Newbie
  • *
  • Posts: 2
    • View Profile
[SFML 2.0] Getting mouse input/coordinates
« on: July 14, 2012, 08:43:31 pm »
Well, I'm trying to learn SFML, and I see that it used to be possible to do write:

"window->GetInput().GetMouseY();" 

but in 2.0, I can't see a replacement. 

Anyone care to let me know how I can get this same information in 2.0?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: [SFML 2.0] Getting mouse input/coordinates
« Reply #1 on: July 14, 2012, 08:44:44 pm »
Take a look at the sf::Mouse class.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: [SFML 2.0] Getting mouse input/coordinates
« Reply #2 on: July 14, 2012, 08:59:55 pm »
To be a bit more precise, it's now sf::Mouse::getPosition().y, if it should be relative to your screen resolution and sf::Mouse::getPosition(window).y, if it should be relative to your window, were window is of type sf::RenderWindow.

Here's the link to the documentation.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

imcit

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: [SFML 2.0] Getting mouse input/coordinates
« Reply #3 on: July 14, 2012, 10:05:59 pm »
To be a bit more precise, it's now sf::Mouse::getPosition().y, if it should be relative to your screen resolution and sf::Mouse::getPosition(window).y, if it should be relative to your window, were window is of type sf::RenderWindow.

Here's the link to the documentation.

Thanks, I don't know why that didn't work the first time I tried it.

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: [SFML 2.0] Getting mouse input/coordinates
« Reply #4 on: July 15, 2012, 12:52:15 am »
Everything's explained in the official tutorial.

BillH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [SFML 2.0] Getting mouse input/coordinates
« Reply #5 on: May 03, 2013, 08:59:02 pm »
I tried the sf::Mouse::getPosition(window).y and for some reason (although the function works OK by the way!) the x and y co-ordinates seem to be the wrong way round

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: [SFML 2.0] Getting mouse input/coordinates
« Reply #6 on: May 03, 2013, 09:00:32 pm »
Don't revive old threads for no reason!

Open a new thread, and read this introduction before.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

BillH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [SFML 2.0] Getting mouse input/coordinates
« Reply #7 on: May 04, 2013, 03:14:39 pm »
I wasn't 'reviving an old thread' merely passing on a comment that I thought might be of interest to other users!