SFML community forums
Help => Window => Topic started by: mjtilbrook1 on November 20, 2016, 02:57:32 pm
-
Hi guys, can someone please explain to me as simply as you can how pollEvents work, im struggling to understand them, like, i get the rest of the code, just not the pollEvent part
thanks
while (gameWindow.isOpen())
{
sf::Event event;
while (gameWindow.pollEvent(event))
{
if (event.type == sf::Event::Closed)
gameWindow.close();
}
gameWindow.display();
}
-
Events are stored in a (hidden) list when triggered.
pollEvent removes an event from this list and initializes its sf::Event argument with it, and returns false if the list is empty and true otherwise.
Since you call pollevent as the condition of a while loop, it processes every events in the list until it's empty.
-
thanks i guess that makes sense, thats helped me out a bit, some things are just hard to understand haha :P