Any scene in the kit that is not a playable level is what we’d refer to as a Menu scene (though code wise it’s actually created from the Home.swift file). Menu scenes are capable of exactly what you’d expect: navigating your way to playing the game basically. But you can also add video to a menu scene, and automatically jump back into the game. So they can also be used as “cut scenes” between levels. For example, the character walks through a portal and it takes them to a menu where video plays, then sends them to the next playable level.
The Demo includes 4 menu scenes in the kit, but you can add AS MANY as you want. The data for these scenes resides in the Root of the property list. Circle below, you can see Home, MainMenu, ResetGameMenu and ContinueMenu.
You’ll notice these are the exact same name as corresponding SKS files….
So again, you can create as many extra scene files as you need. Just be sure the base name matches a dictionary in the property list.
Optional – if you want to include alternate iPad-only scenes, then include .sks files with “Pad” at the end of the name. For example, HomePad.sks or MainMenuPad.sks . To avoid having to do this, we’ve included a CameraScale property you can usually use to size up the iPad scale differently for that device.
Most menus will have some buttons, so let’s first take a look at that. Unfold the MainMenu dictionary in the demo and you’ll find a sub-dictionary called Buttons. Inside here you can include as many buttons as you want. The demo includes a button to start the game (StartButton), one that goes to a continue screen which is used to restart the game from various locations (ContinueButton) and then a button that goes to another menu screen which is used to reset the game (GoToResetMenuButton)
In your SKS file, you’ll setup these buttons by texturing a Color Sprite with your button art, then giving it a name…
Next go to the Custom Class tab and set the Custom Class to Button.
You’ll do this for every button you want to include. Just like setting up items / enemies in our scenes, remember that the Name value must match it’s corresponding data in the property list.
Take a look at one of the button dictionaries unfolded…
- ContinueOrStart – a Boolean value, if set to YES, the button will either continue from the last saved point, or it will use the Level and Where properties to start the game from there. See the Continue property below for another way to continue.
- Level – the name of the level the button will take the user to.
- Where – an optional name of an SKNode or SKSpriteNode in the level to act as an entry point for the player. If left blank, the player will be put at the 0,0 location (middle) of the level. SKNode’s are invisible by default and SKSpriteNodes can have their color opacity set to 0, so they are invisible.
- DisableIfNotReached – a Boolean value, if YES the button will be disabled (mostly transparent) if the player has not made it to the Level and Where properties.
- DisabledAlpha – a Number value to optionally set the alpha transparency value on a button that is disabled. The default is 0.2 if you exclude this property.
- DisabledImage – a String value for an optional alternate image for the button that will display when the button is disabled. For example, your image might be an icon representing another level, in which case you could include an alternate disable image that shows the icon with a lock over it, or text that says “Not yet reached”.
- SelectedImage – a String value for an optional alternate image for the button that will display when the button is being tapped (when not disabled). Not really that necessary
- Sound – the sound file to play when the button is tapped
- LoadScene – you’ll find an example of this in the ContinueButton in the demo. The LoadScene property will have a value equal to another menu you want to load.
- RemoveIfNoSavedGame – a Boolean value, if YES the button will be removed if there is no previously saved game. (screenshot below)
- ClearSavedData – a Boolean value, if YES, when the user taps this button, it will clear all saved data, wiping out any trace that the game was ever played. You can see an example of this in the ResetGameMenu > Buttons > ResetButton (screenshot below). You don’t want to make this button accidentally pushable, so it should go on it’s own menu screen only dedicated to resetting the game. Or excluded altogether (our recommendation).
- Continue – A Bool value, if YES the button will act as a general continue button and take the player to their most recent saved continue point (for reference on how to make a level a save point, see this article, about the ContinuePoint property). If there is no previous save point, the button will be disable and semi-transparent.
- RequiresProduct – a String value for the In-App Purchase product that is required for this button to function. You could disable any button, but this is mostly intended for buttons that allow the user to go to specific levels. See the image below for an example. If the product has not been purchased, tapping this button will launch an In-App Purchase prompt.
- UnBoughtImage – a String value for an optional alternate image for the button that will display when the button requires a purchase that hasn’t been bought. For example, your image might be an icon representing another level, in which case you could include an alternate un-bought image that shows the icon with a lock over it, or text that says “Purchase this Level”. If purchase the button image will switch to the DisabledImage (if the button requires reaching a save point), or it will switch to the initial texture (setup in the Scene file).
- RestoresPurchases – a Bool value, when set to YES, the only thing the button does is restore purchases. If you sell a Non-Consumable in-app purchase in your game, this button is required. Non-Consumable is the type of product you would want for selling access to levels. So once bought, the user wouldn’t need to buy access again.
Below are some non-Button related properties. Let’s start by looking at the Home menu in the demo, which doesn’t have any buttons at all. Instead it plays a short video clip then automatically goes to the MainMenu scene.
Let’s look at the three options you have to play back video. All three require that you add a Color Sprite (SKSpriteNode) to the scene to act as a placeholder for where the video will go. This must be named VideoPlaceholder.
The z position of the sprite will be used for the video, so in this manner, you can position other things above the video. For example, your logo could be in front, and you include some looping effect behind it. You can also rotate the video and in our example, we rotated the video -90 degrees because the video we had was landscape, but the game is portrait (in a real app, you wouldn’t want to do that). So here are the video properties…
- PlayVideoOnce – the value will be the name of an mp4 file you’ve imported to the kit. This video playback option will remove the video after it has finished.
- PlayLoopingVideo – the value will be the name of an mp4 file you’ve imported to the kit. This video playback option will loop the video after it has finished.
- PlayVideo – the value will be the name of an mp4 file you’ve imported to the kit. . This video playback option will simply stop on the final frame of the video when it has finished.
You can make a scene automatically jump to another scene or to a level using the AutoLoad dictionary. In the example below, the current scene would open the MainMenu scene after 3 seconds.
In the alternate example below, the AutoLoad dictionary would load the Grassland level and send the player to the EntryPoint after 3 seconds.
So your only 4 properties in the AutoLoad dictionary are…
- Scene – the scene name.
- Level – the level name
- Where – the node name in the level to act as the entry point.
- Wait – a Number value
Sound and Camera Properties
- CameraScale – if you include a camera in the scene, this will be a number value to adjust the camera on the iPad only. This has no effect on the iPhone.
- MP3Loop – a looping mp3 file to play. Do NOT include .mp3 in the value.
- IntroSound – the full file name, including file extension, of a sound file to initially play when the scene loads. The .mp3 or .caf filetypes are recommended.