Class CPAnimation

CPObject
    extended byCPAnimation

@implementation CPAnimation : CPObject

Manages an animation. Contains timing and progress information.


Method Summary
-(id)initWithDuration:(float)aDuration animationCurve:(CPAnimationCurve)anAnimationCurve
          Initializes the animation with a duration and animation curve.
-(CPAnimationCurve)animationCurve
          Returns the animation's pace.
-(float)currentProgress
          Returns the animation's progress.
-(float)currentValue
          Returns the animation's timing progress.
-(id)delegate
          Returns the animation's delegate.
-(CPTimeInterval)duration
          Returns the length of the animation.
-(float)frameRate
          Returns the desired frame rate.
-(BOOL)isAnimating
          Returns YES if the animation is running.
-(void)setAnimationCurve:(CPAnimationCurve)anAnimationCurve
          Sets the animation's pace.
-(void)setCurrentProgress:(float)aProgress
          Sets the animation's progress.
-(void)setDelegate:(id)aDelegate
          Sets the animation's delegate.
-(void)setDuration:(CPTimeInterval)aDuration
          Sets the animation's length.
-(void)setFrameRate:(float)frameRate
          Sets the animation frame rate.
-(void)startAnimation
          Starts the animation.
-(void)stopAnimation
          Stops the animation before it has completed.

Methods inherited from class CPObject
initialize, alloc, class, instanceMethodForSelector, instancesRespondToSelector, isSubclassOfClass, load, new, setVersion, superclass, version, init, autorelease, awakeAfterUsingCoder, class, classForCoder, classForKeyedArchiver, className, copy, dealloc, description, doesNotRecognizeSelector, forwardInvocation, hash, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableCopy, performSelector, performSelector, performSelector, release, replacementObjectForArchiver, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, retain, self, superclass

Delegate Method Summary
-(BOOL)animationShouldStart:(CPAnimation)animation
          Called at the beginning of startAnimation.
-(void)animationDidEnd:(CPAnimation)animation
          Called when an animation has completed.
-(void)animationDidStop:(CPAnimation)animation
          Called when the animation was stopped (before completing).
-(float)animation:(CPAnimation)animation valueForProgress:(float)progress
          The value from this method will be returned when CPAnimation's currentValue method is called.


Method Detail

initWithDuration

-(id)initWithDuration:(float)aDuration animationCurve:(CPAnimationCurve)anAnimationCurve
Initializes the animation with a duration and animation curve.
Parameters:
aDuration - the length of the animation
anAnimationCurve - defines the animation's pace
Throws:
CPInvalidArgumentException - if an invalid animation curve is specified

animationCurve

-(CPAnimationCurve)animationCurve
Returns the animation's pace

currentProgress

-(float)currentProgress
Returns the animation's progress

currentValue

-(float)currentValue
Returns the animation's timing progress.

delegate

-(id)delegate
Returns the animation's delegate

duration

-(CPTimeInterval)duration
Returns the length of the animation.

frameRate

-(float)frameRate
Returns the desired frame rate.

isAnimating

-(BOOL)isAnimating
Returns YES if the animation is running.

setAnimationCurve

-(void)setAnimationCurve:(CPAnimationCurve)anAnimationCurve
Sets the animation's pace.
Parameters:
anAnimationCurve - the animation's pace
Throws:
CPInvalidArgumentException - if an invalid animation curve is specified

setCurrentProgress

-(void)setCurrentProgress:(float)aProgress
Sets the animation's progress.
Parameters:
aProgress - the animation's progress

setDelegate

-(void)setDelegate:(id)aDelegate
Sets the animation's delegate.
Parameters:
aDelegate - the new delegate

setDuration

-(void)setDuration:(CPTimeInterval)aDuration
Sets the animation's length.
Parameters:
aDuration - the new animation length
Throws:
CPInvalidArgumentException - if aDuration is negative

setFrameRate

-(void)setFrameRate:(float)frameRate
Sets the animation frame rate. This is not a guaranteed frame rate. 0 means to go as fast as possible.
Parameters:
frameRate - the new desired frame rate
Throws:
CPInvalidArgumentException - if frameRate is negative

startAnimation

-(void)startAnimation
Starts the animation. The method calls animationShouldStart: on the delegate (if it implements it) to see if the animation should begin.

stopAnimation

-(void)stopAnimation
Stops the animation before it has completed.

Delegate Method Detail

animationShouldStart

-(BOOL)animationShouldStart:(CPAnimation)animation
Called at the beginning of startAnimation.
Parameters:
animation - the animation that will start
Returns:
YES allows the animation to start. NO stops the animation.

animationDidEnd

-(void)animationDidEnd:(CPAnimation)animation
Called when an animation has completed.
Parameters:
animation - the animation that completed

animationDidStop

-(void)animationDidStop:(CPAnimation)animation
Called when the animation was stopped (before completing).
Parameters:
animation - the animation that was stopped

animation

-(float)animation:(CPAnimation)animation valueForProgress:(float)progress
The value from this method will be returned when CPAnimation's currentValue method is called.
Parameters:
animation - the animation to obtain the curve value for
progress - the current animation progress
Returns:
the curve value

Created on Sat Sep 13 14:15:43 PDT 2008