Skip to content

Instantly share code, notes, and snippets.

@zackproser
Created July 12, 2015 20:26
Show Gist options
  • Save zackproser/b35659cd2b61dfdc581e to your computer and use it in GitHub Desktop.
Save zackproser/b35659cd2b61dfdc581e to your computer and use it in GitHub Desktop.
An example of initializing a custom game save system while setting up a Phaser game level.
//////////////////////
//READ LOCAL STORAGE
//////////////////////
this.playerStats;
if (localStorage.getItem('Canyon_Runner_9282733_playerStats') != null) {
this.playerStats = JSON.parse(localStorage.getItem('Canyon_Runner_9282733_playerStats'));
} else {
this.playerStats = { topScore: 0, topTime: 0, returnPlayerToState: 'HowToPlay'};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment