Exploring the SpriteKit demo

Use the project navigator to open up the file named GameScene.swift. Xcode created GameScene.swift to store the default scene of our new game.

What is a scene? SpriteKit uses the concept of scenes to encapsulate each unique area of a game. Think of the scenes in a movie; we will create a scene for the main menu, a scene for the Game Over screen, a scene for each level in our game, and so on. If you are on the main menu of a game and you tap Play, you move from the menu scene to the Level 1 scene.

SpriteKit prepends its class names with the letters "SK"; consequently, the scene class is SKScene.

You will see that there is already some code in this scene. The SpriteKit project template comes with a very short demo. Let's ...

Get Swift Game Development - Third Edition 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.