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 ...

Get Build iOS Games with Sprite Kit now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.