Game Development Reference
In-Depth Information
Listing 6-14. ImageRepresentation.h
#import <Foundation/Foundation.h>
#import "Actor.h"
@protocol ImageRepresentationDelegate
@required
-(NSString*)baseImageName;
@optional
-(int)getFrameCountForVariant:(int)aVariant AndState:(int)aState;
-(NSString*)getNameForVariant:(int)aVariant;
UIView* view;
+(id)imageRep;
+(id)imageRepWithName:(NSString*)aBaseImageName;
+(id)imageRepWithDelegate:(NSObject<ImageRepresentationDelegate>*)aDelegate;
-(void)advanceFrame:(Actor*)actor ForStep:(int)step;
-(NSString*)getImageNameForActor:(Actor*)actor;
-(UIImage*)getImageForActor:(Actor*)actor;
@end
The goal of the ImageRepresentation class is to encapsulate code for handling the common ways
images will be used to represent an actor. These include the following cases:
A single image representing the actor
A series of images representing the actor
Actors with multiple states
Actors with multiple variations
Actors with a different number of images for every combination of states
and variations
Each actor we create that uses an ImageRepresentation will fit one of the preceding cases. We indicate
which one of these cases we intend by setting a delegate of type I mageRepresentationDelegate , as
shown in Listing 6-14. This allows an instance of ImageRepresentationDelegate to indicate the name
of the image that should be used at any given time.
Search WWH ::




Custom Search