Game Development Reference
In-Depth Information
Chapter
8
Transitioning Between Scenes
In the previous chapter, you saw how to use SKLabelNode s to add labels to your Sprite
Kit games. Specifically, you saw how to display the remaining number of impulses and
how to add scoring to the game to keep up with the number of orbs the SuperSpaceMan has
collected. At the end of the chapter, you got a chance to revisit SKAction s when you ad-
ded sound to the game.
In this chapter, you will learn how to implement scene transitions using Sprite Kit's
SKTransition class. You will get a look at some of the different types of built-in trans-
itions Sprite Kit makes available to you. You will also see how you can control each scene
during a transition. At the end of the chapter, you will take your newfound knowledge and
add a menu scene to your SuperSpaceMan game.
Transitioning
Between
Scenes
Using
SKTransitions
As you already know, SKScene s are the components you use to present game content to
users, and a well-designed game will group related content in individual scenes. For ex-
ample, you could use different scenes to present different levels of a game, or you could
use a scene to present a menu of options to a player.
To provide smooth transitions between scenes, Sprite Kit provides the SKTransition
class. Using SKTransitions is accomplished using three steps.
1.
Create the SKScene you want to transition in to.
2.
Use one of the class-level SKTransition methods to create the transition
you want to use.
3.
Use the SKView 's presentScene(scene: SKScene?, trans-
ition: SKTransition?) method to present the new scene.
Search WWH ::




Custom Search