O'Reilly logo

Learning iOS 8 Game Development Using Swift by Siddharth Shekar

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

Resetting the high score count

What if the player wants to reset their high score to zero? We can do this by adding a button in the main menu and resetting the value of the key to zero.

Open the MainMenuScene.swift file, and in the didMoveToView function where we created the play button, create one more SKSpriteNode called resetBtn. Place this button at three-fourth of the width of the screen and name the sprite resetBtn. We will use the name to check whether the player clicked the play button or the reset button.

The assets for the reset button are in the Resources folder, so create a new image set called resetBtn and drag-and-drop resetBtn.png and resetBtn2.png to the 1x and 2x placeholders, respectively, as shown in the following:

let resetBtn ...

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