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 theBackgrounds Sprite Atlas
. You should have a sprite calledbackground-menu
with the background textures for the menu scene. If not, you can find these two textures in theBackgrounds 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 { ...