Due to security considerations, Windows Phone isolates applications from each other and does not provide means like shared file system to persist data from applications. This is why we need a special means, the Isolated storage, to persist the state of our game.
Task 1 – Utilize Tombstoning and Isolated storage to store the game state
Though Tombstoning and Isolated storage have similar capabilities, they both can store the game state, we use them in different scenarios.
We use Tombstoning to store the state of the game when we launch another application, e.g. via the "Start" button or using the above-mentioned Choosers and Launchers.
We use Isolated storage to store the state of the game when are going to exit the game, but want to continue next time from the same place. We exit the game, e.g. via "Back" button when we go before the first page of the game or when we explicitly call the "Exit" method of the Game class.
Fortunately, Windows Phone itself recognizes those scenarios and raises appropriate events, which we may handle in our game.
In this task, we extend the CatapultGame class with event handlers that save and restore the application state using Tombstoning and Isolated storage capabilities and assign those handlers to the correspondent events raised by the Windows Phone:
Open the CatapultGame.cs file.
Replace the "Using Statements" region with the following code:
#region Using Statements
Page | 90