Adding a high score to local storage

后端 未结 5 1755
轻奢々
轻奢々 2021-01-06 16:37

I want to add a high score to my game. Right now I have this:

var score = 0;
var highscore = 0;

The score variable works but whenever I get

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-06 17:13

    I just reviewed your code in http://jsfiddle.net/unb8yLj3/ and i couldn't find in what part you increase the score so when this part of code run score is 0 and localStorage.getItem("highscore") is 10 therefore it doesn't set highscore.

    if (score > localStorage.getItem("highscore")) {
                    localStorage.setItem("highscore", score);
    
                }
    
      }
    

    Is there another js file that does increase the score?

提交回复
热议问题