Game Development Reference
In-Depth Information
// TODO: This application has been reactivated from suspension.
// Restore application state here.
}
args.setPromise(WinJS.UI.processAll());
}
};
app.oncheckpoint = function (args) {
// TODO: This application is about to be suspended. Save any state
// that needs to persist across suspensions here. You might use the
// WinJS.Application.sessionState object, which is automatically
// saved and restored across suspension. If you need to complete an
// asynchronous operation before your application is suspended, call
// args.setPromise().
};
app.start();
})();
Luckily for us, the files are heavily commented. As you can see, there are two places you
will need to manage your game being initialized: when the game is launched for the first
time and when the app has been reactivated from being suspended.
This is similar to the window.onload or document.load where you would wait until the entire
page is loaded then execute the code to run your game. I highly suggest that you modify your
game to be initialized here instead of running on its own in the default.html file. This will al-
low you to better integrate your game into the Windows 8 app lifecycle and give you more
control over how your game behaves based on being loaded up or resuming. The best part is
that if your game already has some method for initializing it after the page is ready you can
probably just comment that out in your index.html page and use this file to call the same
method.
NOTE
It's up to you if you want to place your game's initialization code into the default.js file.
Your game will run perfectly fine on its own inside of the default.html file, but you will
not be able to handle any resume logic on your own unless you build that into your
game's own code. Likewise, you can skip the default.js logic and simply put this in your
own game's code. All you need is a reference to WinJS.Application and the activation
callback since Windows 8 will handle the rest for you.
Search WWH ::




Custom Search