Game Development Reference
In-Depth Information
SKScene willMoveFromView() method. This method is called on an SKScene
when it is about to be removed from a view. To override this method, you add the follow-
ing code to your SKScene implementation:
override func willMoveFromView(view: SKView) {
// insert code
}
The second method is the SKScene didMoveToView() method. This method is
called when the scene has just finished being presented by a view. To override this meth-
od, you add the following code to your SKScene implementation:
override func didMoveToView(view: SKView) {
// insert code
}
Adding a New Scene to SuperSpaceMan
In this section, you will use your newfound knowledge of scene transitions and add a new
scene to the SuperSpaceMan game. The purpose of this scene will be to allow the user to
see the score of their most recent game and to allow them to start a new game.
Before you do anything, let's add a simple message that tells the game player to tap the
screen to start the game. As you know, the game already starts when you tap the screen.
This label is just nice to have to start tidying up the user interface. To add this label, go to
the GameScene 's declaration section and add the following line of code directly before
the first init() method:
let startGameTextNode = SKLabelNode(fontNamed:
"Copperplate")
After you have added this line, go to the bottom of the GameScene 's init(size:
CGSize) method and add the following block of code to the bottom of this method:
startGameTextNode.text = "TAP ANYWHERE TO START!"
startGameTextNode.horizontalAlignmentMode
= SKLabelHorizontalAlignmentMode.Center
startGameTextNode.verticalAlignmentMode
= SKLabelVerticalAlignmentMode.Center
Search WWH ::




Custom Search