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
-
totalDelayUnitstotal Delay units of the CCAnimation.
property -
delayPerUnitDelay in seconds of the “delay unit”
property -
durationduration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit
property -
framesarray of CCAnimationFrames
property -
restoreOriginalFramewhether or not it shall restore the original frame when the animation finishes
property -
loopshow many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, …
property -
+ animationCreates 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
-
namename of the animation
property -
delaydelay 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 delayDeclared In
CCSpriteFrame.hdelayPerUnit
Delay in seconds of the “delay unit”
@property (nonatomic, readwrite) float delayPerUnitDeclared In
CCAnimation.hduration
duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit
@property (nonatomic, readonly) float durationDeclared In
CCAnimation.hframes
array of CCAnimationFrames
@property (nonatomic, readwrite, retain) NSMutableArray *framesDeclared In
CCAnimation.hloops
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 loopsDeclared In
CCAnimation.hname
name of the animation
@property (nonatomic, readwrite, retain) NSString *nameDeclared In
CCSpriteFrame.hClass 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)delayDeclared In
CCAnimationExtensions.hanimationWithFrames: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)delayDeclared In
CCAnimationExtensions.hanimationWithName:
Creates a CCAnimation with a name
+ (id)animationWithName:(NSString *)nameAvailability
Declared In
CCSpriteFrame.hanimationWithName:delay:
Creates a CCAnimation with a name and delay between frames.
+ (id)animationWithName:(NSString *)name delay:(float)delayDeclared In
CCSpriteFrame.hanimationWithName:delay:frames:
Creates a CCAnimation with a name, delay and an array of CCSpriteFrames.
+ (id)animationWithName:(NSString *)name delay:(float)delay frames:(NSArray *)framesDeclared In
CCSpriteFrame.hanimationWithName: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)delayDeclared In
CCAnimationExtensions.hanimationWithName:frames:
Creates a CCAnimation with a name and frames
+ (id)animationWithName:(NSString *)name frames:(NSArray *)framesAvailability
Declared In
CCSpriteFrame.hInstance Methods
addFrame:
Adds a frame to a CCAnimation.
- (void)addFrame:(CCSpriteFrame *)frameDeclared In
CCSpriteFrame.haddFrameWithFilename:
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 *)filenameDeclared In
CCSpriteFrame.haddFrameWithTexture: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)rectDeclared In
CCSpriteFrame.haddSpriteFrame:
Adds a CCSpriteFrame to a CCAnimation. The frame will be added with one “delay unit”.
- (void)addSpriteFrame:(CCSpriteFrame *)frameDeclared In
CCAnimation.haddSpriteFrameWithFilename:
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 *)filenameDeclared In
CCAnimation.haddSpriteFrameWithTexture: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)rectDeclared In
CCAnimation.hinitWithName:
Initializes a CCAnimation with a name
- (id)initWithName:(NSString *)nameAvailability
Declared In
CCSpriteFrame.hinitWithName:delay:
Initializes a CCAnimation with a name and delay between frames.
- (id)initWithName:(NSString *)name delay:(float)delayDeclared In
CCSpriteFrame.hinitWithName:delay:frames:
Initializes a CCAnimation with a name, delay and an array of CCSpriteFrames.
- (id)initWithName:(NSString *)name delay:(float)delay frames:(NSArray *)framesDeclared In
CCSpriteFrame.hinitWithName:frames:
Initializes a CCAnimation with a name and frames
- (id)initWithName:(NSString *)name frames:(NSArray *)framesAvailability
Declared In
CCSpriteFrame.h