When playing mobile games, you will usually find an initial menu screen when you run it. These screens are usually shown to provide players with a way to modify some configurations, such as turning on or turning off of the game sound, the selection of a game's difficulty, or just a way to hide a big load of components.
We are going to create a menu that will be shown when the game is run, where we will show a background and a button to start playing the game.
For this purpose, we will need to create a new scene file to manage this new screen behavior. To do so, perform the following steps:
In Xcode, select the File menu at the top of the screen.
Select New | File, and you will see the Files dialog box.
Select the Swift File option under iOS | Source and click on Next.
Name it
MenuScene
and choose the folder where you want it to be saved before clicking on Create button.
As you will see, the new file is almost empty. So let's fix this by adding the following lines to the MenuScene...