Game Development Reference
In-Depth Information
Template Name
Use
Class-level method that creates a transition
where the new scene moves in on top of the cur-
rent scene
moveInWithDirection(_:duration:)
Class-level method that creates a transition
where the new scene moves in, pushing the cur-
rent scene out of the view
pushWithDirection(_:duration:)
Class-level method that creates a transition
where the current scene moves out of the view,
revealing the new scene underneath it
revealWithDirection(_:duration:)
As you can see, Sprite Kit provides a pretty complete set of built-in transitions. An ex-
ample use of one of these transitions is shown in the following snippet:
let transition = SKTransition.fadeWithDuration(2.0)
let sceneTwo = SceneTwo(size: self.size)
self.view?.presentScene(sceneTwo, transition: transition)
Take a look at this code. The first line of this snippet creates a transition that will fade to
black and then fade to a new scene over a two-second duration. The second line creates
the scene you will be transitioning in to, and the final line actually presents the scene us-
ing the transition.
Pausing Scenes During a Transition
You should be aware of two important SKTransition properties when transitioning
between scenes. They are pausesIncomingScene and pausesOutgoingScene .
These properties are Bool properties used to pause the animation of the incoming and
outgoing scenes, respectively.
If you want a scene's animations to continue during scene transitions, you just set the ap-
propriate property to false before you present the scene. The default value for both of
these properties is true .
Detecting When a New Scene Is Presented
Sprite Kit provides two methods in the SKScene class that you can override to detect
when a scene is being transitioned away from or transitioned in to. The first method is the
Search WWH ::




Custom Search