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

Get Getting Started with SpriteKit 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.