Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var highScore = 100; // you would've set this earlier, of course
- localStorage.setItem("bunnyDefenderHighScore", highScore); // game-specific key in case you later run another game on the same domain
- var highScoreToDisplay = 0;
- if (localStorage.getItem("bunnyDefenderHighScore") !== null) {
- highScoreToDisplay = parseInt(localStorage.getItem("bunnyDefenderHighScore"));
- }
- var gameOverText = this.game.add.text(100, 100, highScoreToDisplay.toString(), {font: "20pt Arial", fill: "#FFFFFF"});
- var score =0;
- var highscore =0;
- var highScoreText;
- var scoreText;
- highScoreText = this.game.add.text(600, 40, 'HS: ' + highscore, {
- font: '25px Arial',
- fill: 'black'
- });
- this.score = 0;
- this.labelScore = game.add.text(20, 20, "0",
- { font: "30px Arial", fill: "black" });
- highScoreText.text = 'HS: ' + localStorage.getItem("highscore");
- {
- if (this.score > localStorage.getItem("highscore"))
- {
- localStorage.setItem("highscore", this.score);
- }
- }
- this.score += 1;
- this.labelScore.text = this.score;
Add Comment
Please, Sign In to add comment