Game Development Reference
In-Depth Information
Figure 5-3 . The CCProgressTimer in action. I would say it's about 10 past 12
The progress timer class is useful for any kind of progress display, like a loading bar or
the time it takes an icon to become available again. Think of the action buttons in
World of Warcraft and their recast timer. The progress timer takes a sprite and, based
on a percentage, displays only part of it to visualize some kind of progress in your
game. Listing 5-15 shows how to initialize the CCProgressTimer node.
Listing 5-15. Initializing a CCProgressTimer Node
// Progress timer is a sprite that is only partially displayed
// to visualize some kind of progress.
CCSprite* fireSprite = [CCSprite spriteWithFile:@"firething.png"];
CCProgressTimer* timer = [CCProgressTimer progressWithSprite:fireSprite];
timer.type = kCCProgressTimerTypeRadial;
timer.percentage = 0;
[self addChild:timer z:1 tag:UILayerTagProgressTimer];
// The update is needed for the progress timer.
[self scheduleUpdate];
The timer type is from the CCProgressTimerType enum defined in CCPro-
gressTimer.h . You can choose between radial and rectangular progress
timers—the latter requires the timer type to be set to kCCProgressTimer-
TypeBar . There's one caveat: the timer doesn't update itself. You have to change the
timer's percentage value frequently to update the progress. That's why I called the
Search Nedrilad ::

Custom Search