Game Development Reference
In-Depth Information
Adding a Callbacks Keyframe
Before resuming the game, it is a good idea to first remove the pause popover menu with
an animation. This gives the user some time to prepare herself for resuming play, perhaps
introducing a 3..2..1 countdown timer after dismissing the pause menu.
Now, theoretically, you could assign an
animationManager.delegate
and imple-
ment the
completedAnimationSequenceNamed:
method to find out if the
resume
game
Timeline is done playing.
However, I haven't explained how to use the
Callbacks
keyframes in the Timeline, and I
haven't explained how they can be used to run custom selectors at any point in the
Timeline. This situation is a good use for a
Callbacks
keyframe. In fact, any time you
need to call a selector at a specific point in time during a Timeline animation, you would
use a
Callbacks
keyframe.
In SpriteBuilder, open the
PauseMenuLayer.ccb
. Left-click on the
Timeline List
(see
Fig-
titled Timeline
. Left-click the
Timeline List
again, and then select
Edit Timelines
to bring
up the same Timelines editing dialog as shown in
Figure 5-9
.
Double-click the
Untitled
Timeline
text to edit it, and rename this Timeline
resume game
. Leave the
Autoplay
check
box unchecked for the
resume game
Timeline, and then click
Done
.
Caution
Once you have more than one timeline in a CCB, it becomes crucial
to verify that you are editing the correct Timeline. Check the
Timeline List
be-
fore making edits, especially if you're wondering why an edit wouldn't change
anything. It may take some time to get used to the idea of switching Timelines,
which you can do by left-clicking the
Timeline List
, and then select the desired
Timeline from the
Timelines
submenu.
Next, edit the Timeline duration by clicking on the digits box in the upper right corner of
the Timeline. (See
Figure 5-2
for reference.) Make the Timeline two seconds long; this
should be enough time. Now move the Timeline Cursor to the end of the timeline at the
2-seconds mark. Here's where you should add a
Callbacks
keyframe.
If you tried to add a
Callbacks
keyframe before you probably couldn't. The trick is to hold
the
Option
key, and then click on the
Callbacks
segment to add a
Callbacks
keyframe.
With a
Callbacks
keyframe added, it still won't do anything yet—you'll have to edit the
keyframe's properties. To do so, double-click the keyframe. A popover like the one shown
Search WWH ::
Custom Search