2
« on: April 17, 2009, 04:21:50 pm »
After searching the best solution to move (scroll) the View using the mouse (pressing left button) I couldn't find anything that help me, so after spending some time trying, I have some usable solution.
Here it is if someone have the same problem!
Variables involved:
sf::Vector2f mouse(0,0); // global variable holding last position of the mouse
sf::View view; //the View asociated to the window
In the Switch handling the events:
while (Window.GetEvent(Event))
{
switch(Event.Type) {
.................
case sf::Event::MouseMoved:
if (!Window.GetInput().IsMouseButtonDown(sf::Mouse::Left)) {
mouse.x=Event.MouseMove.X;
mouse.y=Event.MouseMove.Y;
} else {
view.Move(mouse.x-Window.GetInput().GetMouseX(), mouse.y-Window.GetInput().GetMouseY());
mouse.x=Window.GetInput().GetMouseX();
mouse.y=Window.GetInput().GetMouseY();
}
break;
...................
}
}
Sure It may be some best aproach to do this, but it works for me!.
P.D.: I'm new so, Hello! ( and sorry for my level of english, I'm triying to improve it hehe)
EDIT: Sorry for posting at the wrong board.