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

Creating labels

In almost every game, there are different elements (scores or text labels) to provide visual information to the player and give them an incentive to keep playing in order to beat its score record. In this section, we are going to learn how to add these informative elements to a scene.

In SpriteKit, we have a class named SKLabelNode that inherits from SKNode and provides all the methods and attributes to load fonts and manage every label that we want to show on the screen. We are going to use this class to add a score label at the top-right side of the screen and update it, as the rabbit avoids wrong doors.

Let's start by creating our first label. Then, we will learn how to update it programmatically. For this purpose, we are going ...

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