I've been working on this little framework for my game today and realized that moving delays when moving around. I've used SFML before and have had the same problem, but never bothered to fix it. I'm wondering if anyone has had a similar issue and has found a solution. Here's an example of the code which is giving me the slight pause in movement:

int main(){
    sf::RenderWindow window (sf::VideoMode(640, 480), "Window");

    sf::Texture tex;
    sf::Sprite s;

    while (window.isOpen()){
        sf::Event event;

        while (window.pollEvent(event)){
            if (event.type == sf::Event::Closed)

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
            s.move(0.01f, 0.0f);


The delay/pause/whatever I'm experience is very slight but I can notice it and it's really bugging me. Just seeing the slight break in movement when none of the values alter makes my programming mind extremely sad.

  • 2
    \$\begingroup\$ Can you better define "pause", "delay", and "slight"? What actually happens, specifically? Is it just this particular sprite which pauses while the rest of the game continues to animate? Or does the whole game freeze up for a moment? How long a delay are we talking about, here? A second? A millisecond? When does it happen -- just when you press the button, or continuously, or what? \$\endgroup\$ – Trevor Powell Apr 15 '14 at 0:12

I've had the same type of quirk, and after some experimentation I've found that it's caused by the while (window.pollEvent(event)) loop.

I re-worked my method just to read the message


at the beginning of the

while (window.isOpen()) {

and then go from there. This causes the frame rate to skyrocket, and you'd definitely want to put in a tick System, but unfortunately I'm in class at the moment. When I get home I'll post my code snippet.

  • \$\begingroup\$ What exactly do you mean? This sounds more likely like a bug, either in SFML or in your code? Do you mean you no longer check for all events and only read one? \$\endgroup\$ – Mario Jun 15 '14 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.