Game Development Reference
In-Depth Information
revolution, the label's rotation cancels out their parent sprites' rotation, and thus the labels
remain fixed.
Now I wouldn't have told you to do it in this seemingly dumb way if there wasn't a neat
side-effect to it as well. Right-click the Keyframe Segments for each label, and change
their easing modes to Ease In/Out . You can optionally right-click again and change the
Easing settings to a slightly lower Rate value—for instance, in the range 1,3 to 1,8.
In any case, since the two animations are no longer synchronized—the label's rotation
speeds up and slows down over time thanks to easing—the labels now sway left and right.
Though this is just an odd example you are encouraged to experiment with such stacked
animations. You'll find the most curious ways to animate nodes if you animate the parent
differently than the child.
For instance, imagine you were to move a regular node 200 points to the right with one
easing mode, and move its child sprite node 150 points to the left using a different easing
mode so that the sprite ultimately moves 50 points to the right but has the combined effect
of two different easing modes.
If you run the app now, you should see the logo slide in from the left. The buttons then ap-
pear with their scale animation while the logo is still moving. Once this timeline has
ended, the buttons start rotating.
Tip What if you wanted to have the buttons rotate even while the entry
Timeline is running? There are generally two ways to do so.
One is to duplicate the rotation keyframes for the sprites and their labels in the
entry Timeline. That works well here but would amount to twice the work, and
even more if you ever changed how the buttons rotate.
The alternative is to create a custom CCB document for each button and create
the rotation animation there. However, this means you would have to create a
Custom class for each button's CCB document, though you can use the same
class for both buttons. Obtaining a reference to the MainScene class is still pos-
sible in more than one way. For instance, the following code in the class'
onEnter method obtains a reference to the MainScene object: MainS-
cene* mainScene = (MainS-
cene*)self.scene.children.firstObject;
Search WWH ::




Custom Search