Game Development Reference
In-Depth Information
Figure 5-9 . Creating a new, unused Timeline just to prevent the Default Timeline from playing automatically
You'll notice that the Default Timeline's Autoplay check box is initially checked. First,
try to uncheck it to prevent this Timeline from playing automatically. If this works, all is
good and fine.
But if you can't uncheck it (it's a bug), simply add another Timeline using the + button
and check the Autoplay check box for the new Timeline. This will create a second
Timeline just so that you can check its Autoplay check box to get rid of Autoplay for the
Default Timeline. This workaround was necessary in the SpriteBuilder version I was
working with but may no longer be necessary in the version you are using.
The important aspect here is to uncheck the Autoplay check box one way or another.
Playing Animations Programmatically
Place an instance of the Saw1_noautoplay.ccb in the Level1.ccb , preferably as a
child of the gears and saws node, but in any case under the CCPhysicsNode branch. On
the Item Properties tab, change the saw's Name to sawNoAutoplay . I'm well
known for bad puns, but this one was truly unintentional.
Build and run the app, you will notice the saw won't animate. That's good. Now how to
play it when the time comes?
SpriteBuilder comes with a set of utility classes. You already got acquainted with
CCBReader , which is responsible for loading CCB files. The other most commonly used
SpriteBuilder class is the CCAnimationManager . It's perhaps better known as
CCBAnimationManager , but it has since become an internal class of the Cocos2D engine.
It is responsible for storing and playing animation timelines, which Cocos2D refers to as
sequences .
Search WWH ::




Custom Search