Last active
August 29, 2015 13:57
-
-
Save ekelokorpi/9705601 to your computer and use it in GitHub Desktop.
Storage: Basic usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pandaConfig = { | |
storage: { | |
id: 'com.mycompany.mygame' | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
game.module( | |
'game.main' | |
) | |
.body(function(){ | |
game.createScene('Main', { | |
score: 0, | |
init: function() { | |
// Get value from storage (if none found, return 0) | |
this.highscore = game.storage.get('highscore', 0); | |
}, | |
mousedown: function() { | |
this.score++; | |
if(this.score > this.highscore) { | |
console.log('New highscore: ' + this.score); | |
// Save value to storage | |
game.storage.set('highscore', this.score); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment