Search code examples
javascripthtmlwinjs

WP 8.1 WinJS - How to stop Game Loop?


Everything is working fine, except I cannot seem to stop my game loop when the Start button is being pressed and the app is moved to the background...

app.oncheckpoint = function(args) {}; is not firing any suspend event for Start button.

I am able to stop the loop with Back button using: app.onbackclick = function() {};

But how do I stop the loop with Start button?


Solution

  • try this

    document.addEventListener('msvisibilitychange', function () {
        gameStop();
    });
    

    The msvisibilitychange fires when the app is not visible anymore.