SFML community forums
Help => General => Topic started by: Chuckleluck on November 14, 2011, 08:51:21 pm
-
I'm wanting to pass the position of the mouse in X and Y coordinates as a arguments in a function. I thought the easiest way would be to use Event::MouseMoveEvent(), so I wrote this code:
if(Event.Type == sf::Event::MouseMoved)
HandleMouse(sf::Event::MouseMoveEvent.X, sf::Event::MouseMoveEvent.Y);
This is in the main program loop. However, when I try to run the program, it gives me the error on the line HandleMouse is on:
" error: expected primary-expression before ' . ' token "
I assumed capturing the mouse coordinates was the purpose of MouseMoveEvent. Could someone,
A. Tell me what's wrong with this code, or
B. If MouseMoveEvent isn't the right function, point me to another function that suits my needs.[/quote]
-
sf::Event::MouseMoveEvent is the type, the instance is Event.MouseMove.
So:
Event.MouseMove.X
Event.MouseMove.Y
-
Ah, thank you. :D
EDIT: Are there similar functions for capturing mouse clicking?
-
Of course. Read the doc and tutorials.
And they are not functions, but members of the sf::Event type.