-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Swift Game Development
By :

We can use SpriteKit components to build our main menu. We will create a new scene in a new file for our main menu, and then use code to place a background sprite node, a logo text node, and button sprite nodes. Let's start by adding the menu scene to the project and building out the nodes.
To create the menu scene, follow these steps:
You already added the background texture assets in Chapter 8, Polishing to a Shine—HUD, Parallax Backgrounds, Particles, and More. To double-check, open Assets.xcassets
and locate the Backgrounds Sprite Atlas
. You should have a sprite called background-menu
with the background textures for the menu scene. If not, you can find these two textures in the Backgrounds
folder of the asset bundle.
Add a new Swift file to your project named MenuScene.swift
.
Add the following code to create the MenuScene
scene class:
import SpriteKit class MenuScene: SKScene { // Grab the HUD sprite...