Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #import "GameObject.h"
00011
00012 @implementation GameObject
00013
00014 @synthesize reactsToScreenBoundaries;
00015 @synthesize screenSize;
00016 @synthesize isActive;
00017 @synthesize isCollideable;
00018 @synthesize gameObjectType;
00019
00020 #pragma mark -
00021 #pragma mark Initialisation
00022
00027 -(id)init
00028 {
00029 if(self = [super init])
00030 {
00031 winSize = [CCDirector sharedDirector].winSize;
00032 isActive = YES;
00033 isCollideable = YES;
00034 gameObjectType = kObjectTypeNone;
00035 }
00036
00037 return self;
00038 }
00039
00040 #pragma mark -
00041
00046 -(void)changeState:(CharacterStates)_newState
00047 {
00048
00049 }
00050
00056 -(void)updateStateWithDeltaTime:(ccTime)_deltaTime andListOfGameObjects:(CCArray *)_listOfGameObjects
00057 {
00058
00059 }
00060
00065 -(CGRect)adjustedBoundingBox
00066 {
00067
00068
00069
00070 return [self boundingBox];
00071 }
00072
00073 #pragma mark -
00074 #pragma mark Animation Loading
00075
00082 -(CCAnimation*)loadAnimationFromPlistWthName:(NSString*)_animationName andClassName:(NSString*)_className
00083 {
00084 CCAnimation *animationToReturn = nil;
00085 NSDictionary *plistDictionary = [Utils loadPlistFromFile:_className];
00086 if(plistDictionary == nil) { CCLOG(@"GameObject.loadAnimationFromPlistWithName: Error loading %@.plist", _className); return nil; }
00087
00088
00089 NSDictionary *animationSettings = [plistDictionary objectForKey:_animationName];
00090 if(animationSettings == nil) { CCLOG(@"Could not locate animation with name: %@", _animationName); return nil; }
00091
00092
00093 animationToReturn = [CCAnimation animation];
00094 [animationToReturn setDelay:[[animationSettings objectForKey:@"delay"] floatValue]];
00095
00096
00097 NSString *animationFramePrefix = [animationSettings objectForKey:@"filenamePrefix"];
00098 NSString *animationFrames = [animationSettings objectForKey:@"animationFrames"];
00099 NSArray *animationFrameNumbers = [animationFrames componentsSeparatedByString:@","];
00100
00101 for (NSString *frameNumber in animationFrameNumbers)
00102 {
00103 NSString *frameName = [NSString stringWithFormat:@"%@%@.png", animationFramePrefix, frameNumber];
00104 [animationToReturn addFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:frameName]];
00105 }
00106
00107
00108 return animationToReturn;
00109 }
00110
00111 @end