Class cc.Animation
Extends
cc.Class.
Defined in: CCAnimation.js.
Constructor Attributes | Constructor Name and Description |
---|---|
A cc.Animation object is used to perform animations on the cc.Sprite objects. |
Method Attributes | Method Name and Description |
---|---|
addSpriteFrame(frame)
adds a frame to a cc.Animation The frame will be added with one "delay unit".
|
|
addSpriteFrameWithFile(fileName)
Adds a frame with an image filename.
|
|
addSpriteFrameWithTexture(texture, rect)
Adds a frame with a texture and a rect.
|
|
copy(pZone)
|
|
copyWithZone(pZone)
|
|
<static> |
cc.Animation.create(frames, delay, loops)
Creates an animation.
|
<static> |
cc.Animation.createWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops)
Creates an animation with an array of cc.AnimationFrame, the delay per units in seconds and and how many times it should be executed.
|
ctor()
Constructor
|
|
return Delay in seconds of the "delay unit"
|
|
return duration in seconds of the whole animation.
|
|
return array of CCAnimationFrames
|
|
getLoops()
return how many times the animation is going to loop.
|
|
return whether or not it shall restore the original frame when the animation finishes
|
|
return total Delay units of the cc.Animation.
|
|
initWithAnimationFrames(arrayOfAnimationFrames, delayPerUnit, loops)
Initializes a cc.Animation with cc.AnimationFrame
|
|
initWithSpriteFrames(frames, delay)
Initializes a cc.Animation with frames and a delay between frames
|
|
setDelayPerUnit(delayPerUnit)
set Delay in seconds of the "delay unit"
|
|
setFrames(frames)
array of CCAnimationFrames setter
|
|
setLoops(value)
set how many times the animation is going to loop.
|
|
setRestoreOriginalFrame(restOrigFrame)
whether or not it shall restore the original frame when the animation finishes
|
Class Detail
cc.Animation()
A cc.Animation object is used to perform animations on the cc.Sprite objects.
The cc.Animation object contains cc.SpriteFrame objects, and a possible delay between the frames.
You can animate a cc.Animation object by using the cc.Animate action. Example:
//create an animation object var animation = cc.Animation.create(); //add a sprite frame to this animation animation.addFrameWithFile("grossini_dance_01.png"); //create an animate with this animation var action = cc.Animate.create(animation); //run animate this._grossini.runAction(action);
Method Detail
addSpriteFrame(frame)
adds a frame to a cc.Animation The frame will be added with one "delay unit".
- Parameters:
- {cc.SpriteFrame} frame
addSpriteFrameWithFile(fileName)
Adds a frame with an image filename. Internally it will create a cc.SpriteFrame and it will add it. The frame will be added with one "delay unit".
- Parameters:
- {String} fileName
addSpriteFrameWithTexture(texture, rect)
Adds a frame with a texture and a rect. Internally it will create a cc.SpriteFrame and it will add it. The frame will be added with one "delay unit".
- Parameters:
- {cc.Texture2D} texture
- {cc.Rect} rect
copy(pZone)
- Parameters:
- pZone
copyWithZone(pZone)
- Parameters:
- {cc.Animation} pZone
<static>
{cc.Animation}
cc.Animation.create(frames, delay, loops)
Creates an animation.
//Creates an animation var animation1 = cc.Animation.create(); //Create an animation with sprite frames var animFrames = []; var frame = cache.getSpriteFrame("grossini_dance_01.png"); animFrames.push(frame); var animation2 = cc.Animation.create(animFrames); //Create an animation with sprite frames and delay var animation3 = cc.Animation.create(animFrames, 0.2);
- Parameters:
- {Array} frames
- {Number} delay
- {Number} loops
- Returns:
- {cc.Animation}
<static>
{cc.Animation}
cc.Animation.createWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops)
Creates an animation with an array of cc.AnimationFrame, the delay per units in seconds and and how many times it should be executed.
- Parameters:
- {Array} arrayOfAnimationFrameNames
- {Number} delayPerUnit
- {Number} loops
- Returns:
- {cc.Animation}
ctor()
Constructor
{Number}
getDelayPerUnit()
return Delay in seconds of the "delay unit"
- Returns:
- {Number}
{Number}
getDuration()
return duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit
- Returns:
- {Number}
{Array}
getFrames()
return array of CCAnimationFrames
- Returns:
- {Array}
{Number}
getLoops()
return how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ...
- Returns:
- {Number}
{Boolean}
getRestoreOriginalFrame()
return whether or not it shall restore the original frame when the animation finishes
- Returns:
- {Boolean}
{Number}
getTotalDelayUnits()
return total Delay units of the cc.Animation.
- Returns:
- {Number}
initWithAnimationFrames(arrayOfAnimationFrames, delayPerUnit, loops)
Initializes a cc.Animation with cc.AnimationFrame
- Parameters:
- {Array} arrayOfAnimationFrames
- {Number} delayPerUnit
- {Number} loops
initWithSpriteFrames(frames, delay)
Initializes a cc.Animation with frames and a delay between frames
- Parameters:
- {Array} frames
- {Number} delay
setDelayPerUnit(delayPerUnit)
set Delay in seconds of the "delay unit"
- Parameters:
- {Number} delayPerUnit
setFrames(frames)
array of CCAnimationFrames setter
- Parameters:
- {Array} frames
setLoops(value)
set how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ...
- Parameters:
- {Number} value
setRestoreOriginalFrame(restOrigFrame)
whether or not it shall restore the original frame when the animation finishes
- Parameters:
- {Boolean} restOrigFrame