Game Development Reference
In-Depth Information
on the screen. In this section, we will look at how Actor is implemented, followed by some concrete
examples. Let's start by taking a look at the header file of the Actor class, shown in Listing 6-9.
Listing 6-9. Actor.h
#import <Foundation/Foundation.h>
@class GameController, Actor;
@protocol Representation
-(UIView*)getViewForActor:(Actor*)anActor In:(GameController*)aController;
-(void)updateView:(UIView*)aView ForActor:(Actor*)anActor In:(GameController*)aController;
@end
@protocol Behavior
-(void)applyToActor:(Actor*)anActor In:(GameController*)gameController;
@end
long nextId;
@interface Actor : NSObject {
}
//State
@property (nonatomic, strong) NSNumber* actorId;
@property (nonatomic) BOOL added;
@property (nonatomic) BOOL removed;
//Geometry
@property (nonatomic) CGPoint center;
@property (nonatomic) float rotation;
@property (nonatomic) float speed;
@property (nonatomic) float radius;
//Behavoir
@property (nonatomic, strong) NSMutableArray<Behavior>* behaviors;
//Representation
@property (nonatomic) BOOL needsViewUpdated;
@property (nonatomic, strong) NSObject<Representation>* representation;
@property (nonatomic) int variant;
@property (nonatomic) int state;
@property (nonatomic) float alpha;
-(id)initAt:(CGPoint)aPoint WithRadius:(float)aRadius
AndRepresentation:(NSObject<Representation>*)aRepresentation;
-(void)step:(GameController*)controller;
-(BOOL)overlapsWith: (Actor*) actor;
-(void)addBehavior:(NSObject<Behavior>*)behavior;
+(CGPoint)randomPointAround:(CGPoint)aCenter At:(float)aRadius;
@end
4
Search WWH ::




Custom Search