-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathCCAnimationManager.h
163 lines (121 loc) · 5.56 KB
/
CCAnimationManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* cocos2d for iPhone: http://www.cocos2d-iphone.org
*
* Copyright (c) 2013 Apportable Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#import "CCBSequenceProperty.h"
@class CCBSequence;
#pragma mark Animation Manager Delegate
/**
The animation manager delegate receives callbacks when animation sequences finishes playing.
Used by CCAnimationManager.
*/
@protocol CCBAnimationManagerDelegate <NSObject>
/**
* Called when an animation sequence has finished playing.
* @param name The name of the sequence that just finished playing.
*/
- (void) completedAnimationSequenceNamed:(NSString*)name;
@end
#pragma mark Animation Manager
/**
The animation manager plays back animations, usually created by a tool such as CocosBuilder.
Any animation can have an arbitrary number of sequences (timelines) which each have keyframes for different properties.
@note Animation names are case sensitive.
*/
@interface CCAnimationManager : NSObject <CCSchedulerTarget>
{
NSMutableDictionary* _nodeSequences;
NSMutableDictionary* _baseValues;
NSInteger _animationManagerId;
CCBSequence* _runningSequence;
CCBSequence* _lastSequence;
void (^block)(id sender);
CCScheduler* _scheduler;
NSMutableArray* _currentActions;
}
/** @name Altering Animation Playback */
/// If set to true the animation manager will run on a fixed time step. This is required to run animations synchronized with physics updates.
@property (nonatomic,assign) bool fixedTimestep;
/// Playback speed, default is 1 and corresponds to the normal playback speed. Use this property for fast forward or slow motion playback.
@property (nonatomic,assign) float playbackSpeed;
/// Set to true to pause the animation currently being run.
@property (nonatomic,assign) bool paused;
/** @name Playing Animations */
/// The name of the currently running sequence (timeline).
@property (unsafe_unretained, nonatomic,readonly) NSString* runningSequenceName;
/**
* Plays an animation sequence (timeline) by its name.
* @param name The name of the sequence to play.
* @see runAnimationsForSequenceNamed:tweenDuration:
* @see runningSequenceName
*/
- (void) runAnimationsForSequenceNamed:(NSString*)name;
/**
* Plays an animation sequence (timeline) by its name, tweens smoothly to the new sequence.
* @param name The name of the sequence to play.
* @param tweenDuration Time to tween to the new sequence.
* @see runAnimationsForSequenceNamed:
* @see runningSequenceName
*/
- (void) runAnimationsForSequenceNamed:(NSString*)name tweenDuration:(float)tweenDuration;
#pragma mark Time Controls
//Renamed to jumpToSequenceNamed:time
//- (void)timeSeekForSequenceNamed:(NSString*)name time:(float)time __attribute__((deprecated));
/**
* Jumps to a specific time in a specific sequence (timeline).
* @param name The name of the sequence to jump to.
* @param time The time in the sequence.
*/
- (void)jumpToSequenceNamed:(NSString*)name time:(float)time;
/** @name Animation Playback Ended */
/// The name of the last completed sequence (timeline).
@property (nonatomic,readonly) NSString* lastCompletedSequenceName;
/**
* Sets a block to be called when an animation sequence has finished playing.
* @param b The block to call.
*/
-(void) setCompletedAnimationCallbackBlock:(void(^)(id sender))b;
/// The animation manager delegate receives updates about the animation playback state.
/// @see CCBAnimationManagerDelegate
@property (nonatomic,weak) NSObject<CCBAnimationManagerDelegate>* delegate;
// Sequence Array
@property (nonatomic,readonly) NSMutableArray* sequences;
// Auto play sequence id.
@property (nonatomic,assign) int autoPlaySequenceId;
// Base node.
@property (nonatomic,unsafe_unretained) CCNode* rootNode;
// (CCB) Optional owner
@property (nonatomic,unsafe_unretained) id owner;
// (CCB) Resolution and default container size.
@property (nonatomic,assign) CGSize rootContainerSize;
// (CCB) Node Management
- (CGSize) containerSize:(CCNode*)node;
- (void) addNode:(CCNode*)node andSequences:(NSDictionary*)seq;
- (void) moveAnimationsFromNode:(CCNode*)fromNode toNode:(CCNode*)toNode;
// Reset node state.
- (void) setBaseValue:(id)value forNode:(CCNode*)node propertyName:(NSString*)propName;
- (void) runAnimationsForSequenceId:(int)seqId tweenDuration:(float) tweenDuration;
- (void)timeSeekForSequenceId:(int)seqId time:(float)time;
#pragma mark Simple Sequence Builder
- (void)addKeyFramesForSequenceNamed:(NSString*)name propertyType:(CCBSequencePropertyType)propertyType frameArray:(NSArray*)frameArray node:(CCNode *)node loop:(BOOL)loop;
@end