O'Reilly logo

Build iOS Games with Sprite Kit by Josh Smith, Jonathan Penn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Showing the High Score

We’re finished building the heads-up display, but because this is all part of showing the score to the player, we need a quick and simple high-score system. Nothing fancy, just enough to display the highest score on the main menu screen so the player can brag.

We could keep track of high scores in many ways. We could place them in a plist file in the game’s documents directory or keep track of them entirely within Apple’s Game Center service. To keep things simple, we’ll use NSUserDefaults, where an iOS application can store preferences or configurations that should be backed up and restored along with the app.

Because the RCWHUDNode is the sole authority about the player’s score, let’s update the ‑endGame method in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required