diff options
| author | Starla Insigna <starla4444@gmail.com> | 2011-07-30 11:19:14 -0400 |
|---|---|---|
| committer | Starla Insigna <starla4444@gmail.com> | 2011-07-30 11:19:14 -0400 |
| commit | 9cd57b731ab1c666d4a1cb725538fdc137763d12 (patch) | |
| tree | 5bac45ae5157a1cb10c6e45500cbf72789917980 /libs/cocos2d/CCAction.h | |
| download | cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.gz cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.bz2 cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.zip | |
Initial commit (version 0.2.1)
Diffstat (limited to 'libs/cocos2d/CCAction.h')
| -rwxr-xr-x | libs/cocos2d/CCAction.h | 195 |
1 files changed, 195 insertions, 0 deletions
| diff --git a/libs/cocos2d/CCAction.h b/libs/cocos2d/CCAction.h new file mode 100755 index 0000000..51bad8e --- /dev/null +++ b/libs/cocos2d/CCAction.h | |||
| @@ -0,0 +1,195 @@ | |||
| 1 | /* | ||
| 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org | ||
| 3 | * | ||
| 4 | * Copyright (c) 2008-2010 Ricardo Quesada | ||
| 5 | * Copyright (c) 2011 Zynga Inc. | ||
| 6 | * | ||
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 8 | * of this software and associated documentation files (the "Software"), to deal | ||
| 9 | * in the Software without restriction, including without limitation the rights | ||
| 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 11 | * copies of the Software, and to permit persons to whom the Software is | ||
| 12 | * furnished to do so, subject to the following conditions: | ||
| 13 | * | ||
| 14 | * The above copyright notice and this permission notice shall be included in | ||
| 15 | * all copies or substantial portions of the Software. | ||
| 16 | * | ||
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 23 | * THE SOFTWARE. | ||
| 24 | * | ||
| 25 | */ | ||
| 26 | |||
| 27 | |||
| 28 | #include <sys/time.h> | ||
| 29 | #import <Foundation/Foundation.h> | ||
| 30 | |||
| 31 | #import "ccTypes.h" | ||
| 32 | |||
| 33 | enum { | ||
| 34 | //! Default tag | ||
| 35 | kCCActionTagInvalid = -1, | ||
| 36 | }; | ||
| 37 | |||
| 38 | /** Base class for CCAction objects. | ||
| 39 | */ | ||
| 40 | @interface CCAction : NSObject <NSCopying> | ||
| 41 | { | ||
| 42 | id originalTarget_; | ||
| 43 | id target_; | ||
| 44 | NSInteger tag_; | ||
| 45 | } | ||
| 46 | |||
| 47 | /** The "target". The action will modify the target properties. | ||
| 48 | The target will be set with the 'startWithTarget' method. | ||
| 49 | When the 'stop' method is called, target will be set to nil. | ||
| 50 | The target is 'assigned', it is not 'retained'. | ||
| 51 | */ | ||
| 52 | @property (nonatomic,readonly,assign) id target; | ||
| 53 | |||
| 54 | /** The original target, since target can be nil. | ||
| 55 | Is the target that were used to run the action. Unless you are doing something complex, like CCActionManager, you should NOT call this method. | ||
| 56 | @since v0.8.2 | ||
| 57 | */ | ||
| 58 | @property (nonatomic,readonly,assign) id originalTarget; | ||
| 59 | |||
| 60 | |||
| 61 | /** The action tag. An identifier of the action */ | ||
| 62 | @property (nonatomic,readwrite,assign) NSInteger tag; | ||
| 63 | |||
| 64 | /** Allocates and initializes the action */ | ||
| 65 | +(id) action; | ||
| 66 | |||
| 67 | /** Initializes the action */ | ||
| 68 | -(id) init; | ||
| 69 | |||
| 70 | -(id) copyWithZone: (NSZone*) zone; | ||
| 71 | |||
| 72 | //! return YES if the action has finished | ||
| 73 | -(BOOL) isDone; | ||
| 74 | //! called before the action start. It will also set the target. | ||
| 75 | -(void) startWithTarget:(id)target; | ||
| 76 | //! called after the action has finished. It will set the 'target' to nil. | ||
| 77 | //! IMPORTANT: You should never call "[action stop]" manually. Instead, use: "[target stopAction:action];" | ||
| 78 | -(void) stop; | ||
| 79 | //! called every frame with it's delta time. DON'T override unless you know what you are doing. | ||
| 80 | -(void) step: (ccTime) dt; | ||
| 81 | //! called once per frame. time a value between 0 and 1 | ||
| 82 | //! For example: | ||
| 83 | //! * 0 means that the action just started | ||
| 84 | //! * 0.5 means that the action is in the middle | ||
| 85 | //! * 1 means that the action is over | ||
| 86 | -(void) update: (ccTime) time; | ||
| 87 | |||
| 88 | @end | ||
| 89 | |||
| 90 | /** Base class actions that do have a finite time duration. | ||
| 91 | Possible actions: | ||
| 92 | - An action with a duration of 0 seconds | ||
| 93 | - An action with a duration of 35.5 seconds | ||
| 94 | Infitite time actions are valid | ||
| 95 | */ | ||
| 96 | @interface CCFiniteTimeAction : CCAction <NSCopying> | ||
| 97 | { | ||
| 98 | //! duration in seconds | ||
| 99 | ccTime duration_; | ||
| 100 | } | ||
| 101 | //! duration in seconds of the action | ||
| 102 | @property (nonatomic,readwrite) ccTime duration; | ||
| 103 | |||
| 104 | /** returns a reversed action */ | ||
| 105 | - (CCFiniteTimeAction*) reverse; | ||
| 106 | @end | ||
| 107 | |||
| 108 | |||
| 109 | @class CCActionInterval; | ||
| 110 | /** Repeats an action for ever. | ||
| 111 | To repeat the an action for a limited number of times use the Repeat action. | ||
| 112 | @warning This action can't be Sequenceable because it is not an IntervalAction | ||
| 113 | */ | ||
| 114 | @interface CCRepeatForever : CCAction <NSCopying> | ||
| 115 | { | ||
| 116 | CCActionInterval *innerAction_; | ||
| 117 | } | ||
| 118 | /** Inner action */ | ||
| 119 | @property (nonatomic, readwrite, retain) CCActionInterval *innerAction; | ||
| 120 | |||
| 121 | /** creates the action */ | ||
| 122 | +(id) actionWithAction: (CCActionInterval*) action; | ||
| 123 | /** initializes the action */ | ||
| 124 | -(id) initWithAction: (CCActionInterval*) action; | ||
| 125 | @end | ||
| 126 | |||
| 127 | /** Changes the speed of an action, making it take longer (speed>1) | ||
| 128 | or less (speed<1) time. | ||
| 129 | Useful to simulate 'slow motion' or 'fast forward' effect. | ||
| 130 | @warning This action can't be Sequenceable because it is not an CCIntervalAction | ||
| 131 | */ | ||
| 132 | @interface CCSpeed : CCAction <NSCopying> | ||
| 133 | { | ||
| 134 | CCActionInterval *innerAction_; | ||
| 135 | float speed_; | ||
| 136 | } | ||
| 137 | /** alter the speed of the inner function in runtime */ | ||
| 138 | @property (nonatomic,readwrite) float speed; | ||
| 139 | /** Inner action of CCSpeed */ | ||
| 140 | @property (nonatomic, readwrite, retain) CCActionInterval *innerAction; | ||
| 141 | |||
| 142 | /** creates the action */ | ||
| 143 | +(id) actionWithAction: (CCActionInterval*) action speed:(float)rate; | ||
| 144 | /** initializes the action */ | ||
| 145 | -(id) initWithAction: (CCActionInterval*) action speed:(float)rate; | ||
| 146 | @end | ||
| 147 | |||
| 148 | @class CCNode; | ||
| 149 | /** CCFollow is an action that "follows" a node. | ||
| 150 | |||
| 151 | Eg: | ||
| 152 | [layer runAction: [CCFollow actionWithTarget:hero]]; | ||
| 153 | |||
| 154 | Instead of using CCCamera as a "follower", use this action instead. | ||
| 155 | @since v0.99.2 | ||
| 156 | */ | ||
| 157 | @interface CCFollow : CCAction <NSCopying> | ||
| 158 | { | ||
| 159 | /* node to follow */ | ||
| 160 | CCNode *followedNode_; | ||
| 161 | |||
| 162 | /* whether camera should be limited to certain area */ | ||
| 163 | BOOL boundarySet; | ||
| 164 | |||
| 165 | /* if screensize is bigger than the boundary - update not needed */ | ||
| 166 | BOOL boundaryFullyCovered; | ||
| 167 | |||
| 168 | /* fast access to the screen dimensions */ | ||
| 169 | CGPoint halfScreenSize; | ||
| 170 | CGPoint fullScreenSize; | ||
| 171 | |||
| 172 | /* world boundaries */ | ||
| 173 | float leftBoundary; | ||
| 174 | float rightBoundary; | ||
| 175 | float topBoundary; | ||
| 176 | float bottomBoundary; | ||
| 177 | } | ||
| 178 | |||
| 179 | /** alter behavior - turn on/off boundary */ | ||
| 180 | @property (nonatomic,readwrite) BOOL boundarySet; | ||
| 181 | |||
| 182 | /** creates the action with no boundary set */ | ||
| 183 | +(id) actionWithTarget:(CCNode *)followedNode; | ||
| 184 | |||
| 185 | /** creates the action with a set boundary */ | ||
| 186 | +(id) actionWithTarget:(CCNode *)followedNode worldBoundary:(CGRect)rect; | ||
| 187 | |||
| 188 | /** initializes the action */ | ||
| 189 | -(id) initWithTarget:(CCNode *)followedNode; | ||
| 190 | |||
| 191 | /** initializes the action with a set boundary */ | ||
| 192 | -(id) initWithTarget:(CCNode *)followedNode worldBoundary:(CGRect)rect; | ||
| 193 | |||
| 194 | @end | ||
| 195 | |||
