Game Development Reference
In-Depth Information
BOOL _didLoad;
}
Then update the didLoadFromCCB method. Add the highlighted line in Listing 12-2 to
the end of the method. This will mark the node as being fully set up for our intents and
purposes.
Listing 12-2 . The node is considered initialized by the time the didLoadFromCCB method
returns
-(void) didLoadFromCCB
{
[self setup];
_didLoad = YES;
}
The key change here is to override the spriteFrame property setter method, which is
aptly named setSpriteFrame: . It follows the common naming scheme for property
setters ( set with an uppercase first letter of property name, receiving a parameter of prop-
erty type) and getters (same as the property name, taking no parameters and returning the
property type).
Every time the Timeline animation changes the spriteFrame property, you'll need to
run the updateTextureCoordinates method in order to point it to the new area
within the Sprite Sheet texture to draw from. If that isn't done, it will simply keep on
drawing the sprite frame that was set initially.
Add the setSpriteFrame: method of Listing 12-3 to SoftBodyDrawNode.m , prefer-
ably at the very bottom just above the @end line.
Listing 12-3 . Overriding the spriteFrame property setter to update texture coordinates
-(void) setSpriteFrame:(CCSpriteFrame *)spriteFrame
{
[super setSpriteFrame:spriteFrame];
if (_didLoad)
{
[self updateTextureCoordinates];
}
Search WWH ::




Custom Search