if (event.type == sf::Event::LostFocus)
myGame.pause();
if (event.type == sf::Event::GainedFocus)
myGame.resume();
That should be all it takes.
http://www.sfml-dev.org/tutorials/2.0/window-events.php (http://www.sfml-dev.org/tutorials/2.0/window-events.php)
This:
sf::Event event;
while (win.getBase()->GetEvent(event))
{
if (event.Type==sf::Event::LostFocus) return false;
if (event.Type==sf::Event::GainedFocus) return true;
}
Doesn't appear to do anything (there are never any events). What is the reason for this? (Note that I've abstracted the RenderWindow into my own window class for easy graphics lib switching)