Game Development Reference
of the update method that does the actual progressing.
Listing 5-16. The Implementation of the update Method
CCNode* node = [self getChildByTag:UILayerTagProgressTimer];
NSAssert([node isKindOfClass:[CCProgressTimer class]], @"node is not a ←
// Updates the progress timer
CCProgressTimer* timer = (CCProgressTimer*)node;
timer.percentage + = delta * 10;
if (timer.percentage > = 100)
timer.percentage = 0;
You must frequently update the CCProgressTimer node's percentage property as
needed—it won't progress by itself automatically. The progress here is simply the
passing of time. Isn't that what games are all about?
Parallaxing is an effect used in 2D games to give the impression of depth, created by
using layered images that move at different rates. The images in the foreground move
faster relative to the images in the background. Although you can't see the parallax ef-
fect in a static image, Figure 5-4 at least gives you a first impression of a background
made up of individual layers. The clouds are at the very back; the mountains are in
front of the clouds but behind the (ugly) trees. At the very bottom is the road where
you might typically add a player character moving left and right along this scenery.