CCAnimation Class Reference
Inherits from | NSObject |
Conforms to | NSCopying |
Declared in | CCAnimation.h CCSpriteFrame.h |
Overview
A CCAnimation object is used to perform animations on the CCSprite objects.
The CCAnimation object contains CCAnimationFrame objects, and a possible delay between the frames. You can animate a CCAnimation object by using the CCAnimate action. Example:
[sprite runAction:[CCAnimate actionWithAnimation:animation]];
extends CCAnimation
Tasks
Other Methods
-
totalDelayUnits
total Delay units of the CCAnimation.
property -
delayPerUnit
Delay in seconds of the “delay unit”
property -
duration
duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit
property -
frames
array of CCAnimationFrames
property -
restoreOriginalFrame
whether or not it shall restore the original frame when the animation finishes
property -
loops
how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, …
property -
+ animation
Creates an animation
-
+ animationWithSpriteFrames:
Creates an animation with an array of CCSpriteFrame. The frames will be created with one “delay unit”.
-
+ animationWithSpriteFrames:delay:
-
+ animationWithAnimationFrames:delayPerUnit:loops:
-
– initWithSpriteFrames:
Initializes a CCAnimation with an array of CCSpriteFrame. The frames will be added with one “delay unit”.
-
– initWithSpriteFrames:delay:
Initializes a CCAnimation with an array of CCSpriteFrames and a delay between frames in seconds. The frames will be added with one “delay unit”.
-
– initWithAnimationFrames:delayPerUnit:loops:
-
– addSpriteFrame:
Adds a CCSpriteFrame to a CCAnimation. The frame will be added with one “delay unit”.
-
– addSpriteFrameWithFilename:
Adds a frame with an image filename. Internally it will create a CCSpriteFrame and it will add it. The frame will be added with one “delay unit”. Added to facilitate the migration from v0.8 to v0.9.
-
– addSpriteFrameWithTexture:rect:
Adds a frame with a texture and a rect. Internally it will create a CCSpriteFrame and it will add it. The frame will be added with one “delay unit”. Added to facilitate the migration from v0.8 to v0.9.
Other Methods
-
name
name of the animation
property -
delay
delay between frames in seconds.
property -
+ animationWithName:
Creates a CCAnimation with a name
-
+ animationWithName:frames:
Creates a CCAnimation with a name and frames
-
+ animationWithName:delay:
Creates a CCAnimation with a name and delay between frames.
-
+ animationWithName:delay:frames:
Creates a CCAnimation with a name, delay and an array of CCSpriteFrames.
-
– initWithName:
Initializes a CCAnimation with a name
-
– initWithName:frames:
Initializes a CCAnimation with a name and frames
-
– initWithName:delay:
Initializes a CCAnimation with a name and delay between frames.
-
– initWithName:delay:frames:
Initializes a CCAnimation with a name, delay and an array of CCSpriteFrames.
-
– addFrame:
Adds a frame to a CCAnimation.
-
– addFrameWithFilename:
Adds a frame with an image filename. Internally it will create a CCSpriteFrame and it will add it. Added to facilitate the migration from v0.8 to v0.9.
-
– addFrameWithTexture:rect:
Adds a frame with a texture and a rect. Internally it will create a CCSpriteFrame and it will add it. Added to facilitate the migration from v0.8 to v0.9.
Deprecated Methods
KoboldExtensions Methods
-
+ animationWithName:format:numFrames:firstIndex:delay:
Creates a CCAnimation with name, a format string for the consecutively numbered files (eg @“frames_%i.png”), the number of frames, the first index (from where to count numFrames), and delay between frames.
-
+ animationWithFiles:frameCount:delay:
Creates a CCAnimation from individual files. The name is the base name of the files which must be suffixed with consecutive numbers. For example: ship0.png, ship1.png, ship2.png … (name:@“ship” frameCount:3)
-
+ animationWithFrames:frameCount:delay:
Creates a CCAnimation from individual sprite frames. Assumes the sprite frames have already been loaded. The name is the base name of the files which must be suffixed with consecutive numbers. For example: ship0.png, ship1.png, ship2.png … (name:@“ship” frameCount:3)
Properties
delay
delay between frames in seconds.
@property (nonatomic, readwrite, assign) float delay
Declared In
CCSpriteFrame.h
delayPerUnit
Delay in seconds of the “delay unit”
@property (nonatomic, readwrite) float delayPerUnit
Declared In
CCAnimation.h
duration
duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit
@property (nonatomic, readonly) float duration
Declared In
CCAnimation.h
frames
array of CCAnimationFrames
@property (nonatomic, readwrite, retain) NSMutableArray *frames
Declared In
CCAnimation.h
loops
how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, …
@property (nonatomic, readwrite) NSUInteger loops
Declared In
CCAnimation.h
name
name of the animation
@property (nonatomic, readwrite, retain) NSString *name
Declared In
CCSpriteFrame.h
Class Methods
animationWithFiles:frameCount:delay:
Creates a CCAnimation from individual files. The name is the base name of the files which must be suffixed with consecutive numbers. For example: ship0.png, ship1.png, ship2.png … (name:@“ship” frameCount:3)
+ (CCAnimation *)animationWithFiles:(NSString *)name frameCount:(int)frameCount delay:(float)delay
Declared In
CCAnimationExtensions.h
animationWithFrames:frameCount:delay:
Creates a CCAnimation from individual sprite frames. Assumes the sprite frames have already been loaded. The name is the base name of the files which must be suffixed with consecutive numbers. For example: ship0.png, ship1.png, ship2.png … (name:@“ship” frameCount:3)
+ (CCAnimation *)animationWithFrames:(NSString *)frame frameCount:(int)frameCount delay:(float)delay
Declared In
CCAnimationExtensions.h
animationWithName:
Creates a CCAnimation with a name
+ (id)animationWithName:(NSString *)name
Availability
Declared In
CCSpriteFrame.h
animationWithName:delay:
Creates a CCAnimation with a name and delay between frames.
+ (id)animationWithName:(NSString *)name delay:(float)delay
Declared In
CCSpriteFrame.h
animationWithName:delay:frames:
Creates a CCAnimation with a name, delay and an array of CCSpriteFrames.
+ (id)animationWithName:(NSString *)name delay:(float)delay frames:(NSArray *)frames
Declared In
CCSpriteFrame.h
animationWithName:format:numFrames:firstIndex:delay:
Creates a CCAnimation with name, a format string for the consecutively numbered files (eg @“frames_%i.png”), the number of frames, the first index (from where to count numFrames), and delay between frames.
+ (id)animationWithName:(NSString *)name format:(NSString *)format numFrames:(int)numFrames firstIndex:(int)firstIndex delay:(float)delay
Declared In
CCAnimationExtensions.h
animationWithName:frames:
Creates a CCAnimation with a name and frames
+ (id)animationWithName:(NSString *)name frames:(NSArray *)frames
Availability
Declared In
CCSpriteFrame.h
Instance Methods
addFrame:
Adds a frame to a CCAnimation.
- (void)addFrame:(CCSpriteFrame *)frame
Declared In
CCSpriteFrame.h
addFrameWithFilename:
Adds a frame with an image filename. Internally it will create a CCSpriteFrame and it will add it. Added to facilitate the migration from v0.8 to v0.9.
- (void)addFrameWithFilename:(NSString *)filename
Declared In
CCSpriteFrame.h
addFrameWithTexture:rect:
Adds a frame with a texture and a rect. Internally it will create a CCSpriteFrame and it will add it. Added to facilitate the migration from v0.8 to v0.9.
- (void)addFrameWithTexture:(CCTexture2D *)texture rect:(CGRect)rect
Declared In
CCSpriteFrame.h
addSpriteFrame:
Adds a CCSpriteFrame to a CCAnimation. The frame will be added with one “delay unit”.
- (void)addSpriteFrame:(CCSpriteFrame *)frame
Declared In
CCAnimation.h
addSpriteFrameWithFilename:
Adds a frame with an image filename. Internally it will create a CCSpriteFrame and it will add it. The frame will be added with one “delay unit”. Added to facilitate the migration from v0.8 to v0.9.
- (void)addSpriteFrameWithFilename:(NSString *)filename
Declared In
CCAnimation.h
addSpriteFrameWithTexture:rect:
Adds a frame with a texture and a rect. Internally it will create a CCSpriteFrame and it will add it. The frame will be added with one “delay unit”. Added to facilitate the migration from v0.8 to v0.9.
- (void)addSpriteFrameWithTexture:(CCTexture2D *)texture rect:(CGRect)rect
Declared In
CCAnimation.h
initWithName:
Initializes a CCAnimation with a name
- (id)initWithName:(NSString *)name
Availability
Declared In
CCSpriteFrame.h
initWithName:delay:
Initializes a CCAnimation with a name and delay between frames.
- (id)initWithName:(NSString *)name delay:(float)delay
Declared In
CCSpriteFrame.h
initWithName:delay:frames:
Initializes a CCAnimation with a name, delay and an array of CCSpriteFrames.
- (id)initWithName:(NSString *)name delay:(float)delay frames:(NSArray *)frames
Declared In
CCSpriteFrame.h
initWithName:frames:
Initializes a CCAnimation with a name and frames
- (id)initWithName:(NSString *)name frames:(NSArray *)frames
Availability
Declared In
CCSpriteFrame.h