1 decade ago by jsantell
Hey guys,
Been playing around with an idea we came up with at the Philly Game Jam this year and have continued to mess around with it. Needed some solution for local storage for high scores and other values, so pulled it out into a plugin.
Mostly an interface for localStorage with some error handling and convenience methods-- let me know if you have problems with anything or you'd like something to be added!
https://github.com/jsantell/ImpactStorage
High Score Example
Storing JSON Objects example
Been playing around with an idea we came up with at the Philly Game Jam this year and have continued to mess around with it. Needed some solution for local storage for high scores and other values, so pulled it out into a plugin.
Mostly an interface for localStorage with some error handling and convenience methods-- let me know if you have problems with anything or you'd like something to be added!
https://github.com/jsantell/ImpactStorage
High Score Example
this.storage = new ImpactStorage(); // Initialize high score as 0 if 'highScore' does not exist this.storage.initUnset('highScore', 0); var player = this.getEntitiesByType(EntityPlayer)[0]; /* Updates the value of 'highScore' if and only if player.score > this.storage.get('highScore') */ this.storage.setHighest('highScore',player.score);
Storing JSON Objects example
this.storage = new ImpactStorage(); /* Player's velocity is an object stored as vel: {x: 200, y: 100} And that data is now being stored with key playerVel in localStorage */ var player = this.getEntitiesByType(EntityPlayer)[0]; this.storage.set('playerVel',player.vel) // And let's output it for fun alert("Player's x velocity: "+this.storage.get('playerVel').x); alert("Player's y velocity: "+this.storage.get('playerVel').y);