Game Development Reference
In-Depth Information
a second, this may irreversibly remove excess keyframes—namely, those whose
timestamp would now be greater than the Timeline's duration.
Finally, click on the Timeline Chain drop-down menu, and select Default Timeline . This
will have the Timeline loop indefinitely in the game.
Now if you try this out in the game. . . there won't be an animation playing. The sprite
frame keyframes don't have any effect yet because the SoftBodyPlayer.ccb uses a custom
class to perform custom rendering.
Adding
Sprite
Frame
Animations
to
SoftBodyDrawNode
SoftBodyPlayer.ccb uses a custom class called SoftBodyDrawNode . This CCSprite
subclass uses the initially assigned spriteFrame property of CCSprite to initialize
the vertex and texture coordinates for the sprites.
However, it doesn't currently update the texture coordinates when the spriteFrame
property changes. Thus, the sprite frame animation currently has no effect.
To fix this, you'll first have to add an ivar that marks the point in time at which the player
has been initialized. This _didLoad flag is important because initially CCBReader will
assign at least one CCSpriteFrame to the sprite's spriteFrame property, whose set-
ter you're going to override in order to call the updateTextureCoordinates meth-
od every time the sprite frames change.
But the initial spriteFrame assignments should not trigger the updateTex-
tureCoordinates method, as its values may not be set up and initialized yet.
Add the ivar highlighted in Listing 12-1 to the SoftBodyDrawNode implementation in
SoftBodyDrawNode.m .
Listing 12-1 . The _didLoad flag is used to determine whether the node has been fully ini-
tialized
@implementation SoftBodyDrawNode
{
// existing ivars omitted for brevity ...
Search WWH ::




Custom Search