1
SFML projects / Re: Nehe OpenGL Tutorials Converted to SFML
« on: June 27, 2013, 09:26:47 pm »
I've gathered that's the 'correct' way to do it - I saw it says so in Events explained :: "The KeyPressed and KeyReleased events".
My question was: why does the event-handling work fine in the cpp file I linked to?
It listens for movement keys inside the
Non-movement keys, such as Escape to quit, are handled within
If I move the movement-key listening to there, it causes stutter.
The code doesn't work perfectly, mind - moving the mouse causes stutter. I'll probably look at moving it to the correct way using isKeyPressed.
I think I've figured it out now: it works when and only when the key-press event is 'left over' from
This means if I move my mouse around (firing events which are ignored) when holding down the left arrow button, I can cause it to stutter, or even stop, as the event 'left over' is no longer the expected keyboard event, but the mouse event, which is duly ignored.
My question was: why does the event-handling work fine in the cpp file I linked to?
It listens for movement keys inside the
while (myWindow.isOpen())
loop, but outside (and after) thewhile (myWindow.pollEvent(event))
loop.Non-movement keys, such as Escape to quit, are handled within
while (myWindow.pollEvent(event))
If I move the movement-key listening to there, it causes stutter.
The code doesn't work perfectly, mind - moving the mouse causes stutter. I'll probably look at moving it to the correct way using isKeyPressed.
I think I've figured it out now: it works when and only when the key-press event is 'left over' from
while (myWindow.pollEvent(event))
This means if I move my mouse around (firing events which are ignored) when holding down the left arrow button, I can cause it to stutter, or even stop, as the event 'left over' is no longer the expected keyboard event, but the mouse event, which is duly ignored.