Using NSUser Defaults to save a current game score (not high score)?

90 views Asked by At

I am making a game with SpriteKit, and I have two scenes. When the game is over it transitions into the second scene (endScene), where it displays the high score, which is saved using the NSUserDefaults. What I want to do, is also display the current score that the player just got, which will change every time the player plays a new game. I can't figure out how to display this score in the endScene.

1

There are 1 answers

0
Aryaman Goel On BEST ANSWER

Use this to save and retrieve the score:

NSUserDefaults.standardUserDefaults().setInteger(score, forKey: "score") // Save Score
score = NSUserDefaults.standardUserDefaults().integerForKey("score") // Retrieve Score