Game Development Reference
In-Depth Information
Figure 6-2. Power-up detail
The top of Figure 6-2 shows the beginning and the end of the 63 images that make up the rotating
Health power-up with glow. In the example code, you will find six series of images: a glowing version
and a nonglowing version for each of the three types of power-ups. By switching between the
glowing version and the nonglowing version, we can create the blinking effect.
Implementing Our Power-Up Actor
To implement our power-up actor, we have to configure our GameController subclass,
Example01Controller, to add power-ups to our scene. We also have to implement the power-up
actor itself, giving it a way to draw itself and define its motion and behavior. The key classes are
ImageRepresentation and Powerup , but we should start with the updateScene task from the class
Example01Controller, as shown in Listing 6-11.
Listing 6-11. Example01Controller.m (updateScene)
-(void)updateScene{
if (self.stepNumber % (60*5) == 0){
[self addActor:[Powerup powerup: self]];
}
[super updateScene];
}
 
Search WWH ::




Custom Search