O'Reilly logo

iOS Game Development By Example by Samanyu Chopra

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

A scoring system in a game

Adding a scoring or points system in a game makes it more interesting and fun to play. Having a scoring system in the game makes it easier for the players to measure their performance, making the objective clear for the user.

It always makes sense to display the score somewhere on the main screen, so that the player can have a look at the score while playing the game.

Adding a scoring system in our Platformer game

In the first step of adding a scoring system in our game, we create a label node to display the score to the player. The initial variable will be zero.

Creating the Score label

Let's add the following code snippet in the beginning of the GameScene class:

let scoreText = SKLabelNode(fontNamed: "Chalkduster") var score ...

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