O'Reilly logo

Getting Started with SpriteKit by Jorge Jordán

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

2-star challenge: completing the tutorial

You may have realized that the tutorial reappears every time we rerun the game even if it has been completed previously. Now that we know how to store information on the device, let's take advantage of it in order to store information about whether the tutorial has been completed.

Solution

We will need a couple of new variables to support this new behavior. Therefore, add the following lines at the top of GameScene class:

private var isTutorialCompleted: Bool = false
private var kUserDefaultTutorialCompleted = "user_default_tutorial_completed"

We declared a Boolean variable that will act as a flag that represents the user's default value. We also declared a constant that will be used to identify the value ...

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