RSS

(root)/iphone/common : 65 : source/ElAnimation.m

To get this branch, use:
bzr branch /browse/iphone/common

« back to all changes in this revision

Viewing changes to source/ElAnimation.m

Dömötör Gulyás
2010-07-04 17:06:19
Revision ID: dognotdog@gmail.com-20100704150619-3vjoon64s20bvxxw
improved device detection; adds CGPosition animation; adds GLString classes

Show diffs side-by-side

added added

removed removed

44
44
 
45
45
- (void) queueAnimation: (ElAnimation*) anim forKey: (id) key atBeginning: (BOOL) atBegin cancelPending: (BOOL) cancelPending;
46
46
- (NSTimeInterval) now;
 
47
- (NSTimeInterval) currentTime;
47
48
 
48
49
@end;
49
50
 
68
69
        return [[ElAnimationController sharedController] now];
69
70
}
70
71
 
 
72
+ (NSTimeInterval) currentTime
 
73
{
 
74
        return [[ElAnimationController sharedController] currentTime];
 
75
}
 
76
 
71
77
- (void) setStartTime: (NSTimeInterval) time
72
78
{
73
79
        startTime = time;
176
182
 
177
183
@end
178
184
 
 
185
@interface NSObject (ElCGPositionAnimation)
 
186
- (void) setPosition: (CGPoint) p;
 
187
@end
 
188
 
 
189
@implementation ElCGPositionAnimation
 
190
 
 
191
- (BOOL) animateForTime: (NSTimeInterval) time delta: (NSTimeInterval) delta
 
192
{
 
193
        BOOL result = [super animateForTime: time delta: delta];
 
194
 
 
195
        double t = fclamp((time - startTime)/duration, 0.0, 1.0);
 
196
        
 
197
        CGPoint y = CGPointZero;
 
198
        switch (interpolation)
 
199
        {
 
200
                case kElLinearInterpolation:
 
201
                        y.x = linearInterpolation(startPoint.x, endPoint.x, t);
 
202
                        y.y = linearInterpolation(startPoint.y, endPoint.y, t);
 
203
                        break;
 
204
                case kElEaseInInterpolation:
 
205
                        y.x = easyInInterpolation(startPoint.x, endPoint.x, t);
 
206
                        y.y = easyInInterpolation(startPoint.y, endPoint.y, t);
 
207
                        break;
 
208
                case kElEaseOutInterpolation:
 
209
                        y.x = easyOutInterpolation(startPoint.x, endPoint.x, t);
 
210
                        y.y = easyOutInterpolation(startPoint.y, endPoint.y, t);
 
211
                        break;
 
212
                case kElSmoothInterpolation:
 
213
                        y.x = smoothInterpolation(startPoint.x, endPoint.x, t);
 
214
                        y.y = smoothInterpolation(startPoint.y, endPoint.y, t);
 
215
                        break;
 
216
        }
 
217
        
 
218
        [target setPosition: y];
 
219
 
 
220
        return result;
 
221
}
 
222
 
 
223
 
 
224
- (void) dealloc
 
225
{
 
226
        [target release];
 
227
        [super dealloc];
 
228
}
 
229
 
 
230
@synthesize startPoint, endPoint, target;
 
231
 
 
232
@end
 
233
 
179
234
 
180
235
@implementation ElAnimationController
181
236
 

Loggerhead 1.17 is a web-based interface for Bazaar branches