Hello,
How can I move my sprite smoothly since Input is no longer in SFML 2.0?
I've tried to do it this way but it still isn't smooth and there's a "pause" when I press arrow (probably because of those "xx = false" at bot.. but I have no idea how to do that
while(MainWindow.isOpen())
{
Event Event;
while(MainWindow.pollEvent(Event))
{
if(Event.type == Event::Closed)
MainWindow.close();
if(Keyboard::isKeyPressed(Keyboard::Left))
{
left = true;
}
if(Keyboard::isKeyPressed(Keyboard::Right))
{
right = true;
}
if(Keyboard::isKeyPressed(Keyboard::Up))
{
up = true;
}
if(Keyboard::isKeyPressed(Keyboard::Down))
{
down = true;
}
if(left)
sT.move(-5, 0);
if(right)
sT.move(5, 0);
if(up)
sT.move(0, -5);
if(down)
sT.move(0, 5);
}
left = false;
right = false;
up = false;
down = false;
MainWindow.clear();
MainWindow.draw(sBackground);
MainWindow.draw(sT);
MainWindow.display();
}