O'Reilly logo

Starling Game Development Essentials by Juwal Bose

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saving data locally

We will need to store persistent data locally on the device. This can be level details to start the game where the user left off the last time they played, or can be preferences data such as the sound volume, sound on/off, or even the current local leaderboard. Saving the current game state occasionally to pick up where we left off is a recommended feature for any mobile game. Local data can be stored in multiple ways by using SharedObject, EncryptedLocalStore, a custom file, or even an sqlLite database.

Data access using a SharedObject method can be done in the following manner:

private static var so:SharedObject=SharedObject.getLocal("some unique name"); public function store(gameData:Object):void{ so.data[gameName]=gameData; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required