I use Escape as exit in main menu and also as return from sub menu, I tried to make blocking loop when Escape is pressed for a little time like few seconds or more that only return to menu and no close all program.
Here is my code, I tried to change it many times but it doesnt work good.
Please give me addvice if you can. :roll:
This is my waiting code with mentioned blocking loop after draw score in the display.
while(1)
{
sf::Event Event;
App.GetEvent(Event);
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
{
sf::Event Event;
App.GetEvent(Event);
while(App.GetInput().IsKeyDown(sf::Key::Escape))
{
sf::Event Event;
App.GetEvent(Event);
sf::Sleep(0.05);
}
break;
}
if(Event.Type == sf::Event::Closed)
return -1;
sf::Sleep(0.05);
}