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, 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:
We will use a new background image for the menu. Let's add it to our project.
Locate
Background-menu.png
in theBackgrounds
folder of the asset bundle.Open
Images.xcassets
in Xcode, and then drag and dropBackground-menu.png
intoImages.xcassets
to make it available in your project.
Add the following code to create the
MenuScene
scene class:import SpriteKit class MenuScene: SKScene { // Grab the HUD texture atlas: let textureAtlas:SKTextureAtlas = SKTextureAtlas(named:"hud.atlas") // Instantiate a sprite node for the start...