summary refs log tree commit diff stats
path: root/libs/cocos2d/CCActionManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/cocos2d/CCActionManager.h')
-rwxr-xr-xlibs/cocos2d/CCActionManager.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/libs/cocos2d/CCActionManager.h b/libs/cocos2d/CCActionManager.h new file mode 100755 index 0000000..0eeda91 --- /dev/null +++ b/libs/cocos2d/CCActionManager.h
@@ -0,0 +1,111 @@
1/*
2 * cocos2d for iPhone: http://www.cocos2d-iphone.org
3 *
4 * Copyright (c) 2009 Valentin Milea
5 *
6 * Copyright (c) 2008-2010 Ricardo Quesada
7 * Copyright (c) 2011 Zynga Inc.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 * THE SOFTWARE.
26 *
27 */
28
29
30#import "CCAction.h"
31#import "Support/ccCArray.h"
32#import "Support/uthash.h"
33
34typedef struct _hashElement
35{
36 struct ccArray *actions;
37 id target;
38 NSUInteger actionIndex;
39 CCAction *currentAction;
40 BOOL currentActionSalvaged;
41 BOOL paused;
42 UT_hash_handle hh;
43} tHashElement;
44
45
46/** CCActionManager is a singleton that manages all the actions.
47 Normally you won't need to use this singleton directly. 99% of the cases you will use the CCNode interface,
48 which uses this singleton.
49 But there are some cases where you might need to use this singleton.
50 Examples:
51 - When you want to run an action where the target is different from a CCNode.
52 - When you want to pause / resume the actions
53
54 @since v0.8
55 */
56@interface CCActionManager : NSObject
57{
58 tHashElement *targets;
59 tHashElement *currentTarget;
60 BOOL currentTargetSalvaged;
61}
62
63/** returns a shared instance of the CCActionManager */
64+ (CCActionManager *)sharedManager;
65
66/** purges the shared action manager. It releases the retained instance.
67 @since v0.99.0
68 */
69+(void)purgeSharedManager;
70
71// actions
72
73/** Adds an action with a target.
74 If the target is already present, then the action will be added to the existing target.
75 If the target is not present, a new instance of this target will be created either paused or paused, and the action will be added to the newly created target.
76 When the target is paused, the queued actions won't be 'ticked'.
77 */
78-(void) addAction: (CCAction*) action target:(id)target paused:(BOOL)paused;
79/** Removes all actions from all the targers.
80 */
81-(void) removeAllActions;
82
83/** Removes all actions from a certain target.
84 All the actions that belongs to the target will be removed.
85 */
86-(void) removeAllActionsFromTarget:(id)target;
87/** Removes an action given an action reference.
88 */
89-(void) removeAction: (CCAction*) action;
90/** Removes an action given its tag and the target */
91-(void) removeActionByTag:(NSInteger)tag target:(id)target;
92/** Gets an action given its tag an a target
93 @return the Action the with the given tag
94 */
95-(CCAction*) getActionByTag:(NSInteger) tag target:(id)target;
96/** Returns the numbers of actions that are running in a certain target
97 * Composable actions are counted as 1 action. Example:
98 * If you are running 1 Sequence of 7 actions, it will return 1.
99 * If you are running 7 Sequences of 2 actions, it will return 7.
100 */
101-(NSUInteger) numberOfRunningActionsInTarget:(id)target;
102
103/** Pauses the target: all running actions and newly added actions will be paused.
104 */
105-(void) pauseTarget:(id)target;
106/** Resumes the target. All queued actions will be resumed.
107 */
108-(void) resumeTarget:(id)target;
109
110@end
111