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

Other Methods

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

restoreOriginalFrame

whether or not it shall restore the original frame when the animation finishes

@property (nonatomic, readwrite) BOOL restoreOriginalFrame

Declared In

CCAnimation.h

totalDelayUnits

total Delay units of the CCAnimation.

@property (nonatomic, readonly) float totalDelayUnits

Declared In

CCAnimation.h

Class Methods

animation

Creates an animation

+ (id)animation

Availability

Declared In

CCAnimation.h

animationWithAnimationFrames:delayPerUnit:loops:

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:

animationWithFrames:delay:

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

animationWithSpriteFrames:

Creates an animation with an array of CCSpriteFrame. The frames will be created with one “delay unit”.

+ (id)animationWithSpriteFrames:(NSArray *)arrayOfSpriteFrameNames

Availability

Declared In

CCAnimation.h

animationWithSpriteFrames:delay:

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

initWithAnimationFrames:delayPerUnit:loops:

initWithFrames:

initWithFrames:delay:

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

initWithSpriteFrames:

Initializes a CCAnimation with an array of CCSpriteFrame. The frames will be added with one “delay unit”.

- (id)initWithSpriteFrames:(NSArray *)arrayOfSpriteFrameNames

Availability

Declared In

CCAnimation.h

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”.

- (id)initWithSpriteFrames:(NSArray *)arrayOfSpriteFrameNames delay:(float)delay

Availability

Declared In

CCAnimation.h