Game Development Reference
In-Depth Information
In Listing 5-10, we see that the constructor task viper: creates a new Viper02 object and uses
the super-task initAt:WithRadius:AndImage to set up the basic properties of the object. Also, the
property moveToPoint is set to be its current location and the speed is set to .8.
The task step: is the task that is called once per frame of the animation. The implementation of this
task is identical to the implementation of the task updateLocation: from the class Actor01 , as shown
in Listing 5-5.
The last task in Listing 5-10 is the task doCollision:In: , which is called when this Viper02 is
overlapping with an Asteroid02 . This task resets the Viper02 back to the starting location at the
center of the game area and removes the offending Asteroid02 from the game.
Viper02 , you may not see exactly how this is different from the Viper01 .
Asteroid02 , we will see how these actor classes
Asteroid02 is
Asteroid02.h
NSMutableArray* imageNameVariations;
@interface Asteroid02 : Actor02 {
}
+(NSMutableArray*)imageNameVariations;
+(id)asteroid:(Example02Controller*)controller;
@end
In Listing 5-11, the header file for the class Asteroid02 shows that it extends Actor02 and has two
static tasks. There is also an array called imageNameVariations . The array, in combination with the
task imageNameVariations , allows us to create Asteroid02 with similar, but different graphics. Let's
take a look at the implementation of this class and see what that means, as shown in Listing 5-12.
Listing 5-12. Asteroid02.m
#import "Asteroid02.h"
#import "Example02Controller.h"
@implementation Asteroid02
+(id)asteroid:(Example02Controller*)controller{
CGSize gameAreaSize=[controller gameAreaSize];
 
Search WWH ::




Custom Search