Kiwi.Animations.Animation Class
An Animation contains information about a single animation that is held on a AnimationManager. The information that is held is unique to this individual animation and will initially be the same as a Sequence, but if you do ever modify the information held in this Animation the corresponding Sequence will not be updated.
Constructor
Kiwi.Animations.Animation
-
name
-
sequences
-
clock
-
parent
Parameters:
-
name
StringThe name of this anim.
-
sequences
Kiwi.Animations.SequencesThe sequence that this anim will be using to animate.
-
clock
Kiwi.Time.ClockA game clock that this anim will be using to keep record of the time between frames. (Deprecated in v1.2.0, because there is no way to control it.)
-
parent
Kiwi.Components.AnimationManagerThe animation manager that this animation belongs to.
Returns:
Item Index
Methods
Methods
_start
-
[index=null]
Start the animation.
Parameters:
-
[index=null]
Number optionalIndex of the frame in the sequence that is to play. If left as null it just starts from where it left off.
_validateFrame
-
frame
An internal method used to check to see if frame passed is valid or not
Parameters:
-
frame
NumberThe index of the frame that is to be validated.
destroy
()
public
Destroys the anim and all of the properties that exist on it.
nextFrame
()
public
Makes the animation go to the next frame. If the animation is at the end it goes back to the start.
objType
()
String
public
The type of object that this is.
Returns:
"Animation"
pause
()
public
Pauses the current animation.
play
()
public
Plays the animation.
playAt
-
index
Plays the animation at a particular frame.
Parameters:
-
index
NumberIndex of the cell in the sequence that the animation is to start at.
prevFrame
()
public
Makes the animation go to the previous frame. If the animation is at the first frame it goes to the end.
resume
()
public
Resumes the current animation after stopping.
stop
()
public
Stops the current animation from playing.
update
()
public
The update loop.
Properties
_frameIndex
Number
private
The current frame index that the animation is currently upto. Note: A frame index is the index of a particular cell in the Sequence.
_isPlaying
Boolean
private
Whether the animation is currently playing or not.
Default: false
_lastFrameElapsed
Number
private
Clock time on last frame, used to compute current animation frame.
_loop
Boolean
private
If this animation should loop or not.
_onComplete
Kiwi.Signal
private
A Kiwi.Signal that dispatches an event when the animation has come to the end of the animation but is not going to play again.
_onLoop
Kiwi.Signal
private
A Kiwi.Signal that dispatches an event when the animation has come to the end of the animation and is going to play again.
_onPlay
Kiwi.Signal
private
A Kiwi.Signal that dispatches an event when the animation has started playing.
_onStop
Signal
private
A Kiwi.Signal that dispatches an event when the animation has stopped playing.
_onUpdate
Kiwi.Signal
private
A Kiwi.Signal that dispatches an event when the animation has updated/changed frameIndexs.
_parent
Kiwi.Components.AnimationManager
private
The AnimationManager that this animation is a child of.
_reverse
Boolean
private
Indicates whether the animation is playing in reverse or not.
_sequence
Kiwi.Animations.Sequence
private
The sequence on the texture atlas that this animation is based off.
_speed
Number
private
How fast the transition is between cells. Perhaps change to frames per second to reflect actual game speed?
_startTime
Number
private
The starting time of the animation from when it was played. Internal use only.
_tick
Number
deprecated
private
The time at which the animation should change to the next cell
clock
Kiwi.Time.Clock
public
Clock used by this Animation. If it was not set on creation, the Animation will use its parent's entity's clock.
currentCell
Number
public
Returns the current cell that the animation is up to. This is READ ONLY.
frameIndex
Number
public
The current frame index that the animation is currently upto. Note: A frame index is the index of a particular cell in the Sequence.
As of v1.3.0, this property will work properly with floating-point values. They will be rounded down and stored as integers.
isPlaying
Boolean
public
Whether the animation is currently playing or not. Read-only.
length
Number
public
Returns the number of frames that in the animation. Thus the animations 'length'. Note this is READ ONLY.
loop
Boolean
public
If once the animation reaches the end, it should start again from the first cell in the sequence or not.
name
String
public
The name of this animation.
onComplete
Kiwi.Signal
public
A Kiwi.Signal that dispatches an event when the animation has come to the end of the animation but is not going to play again.
onLoop
Kiwi.Signal
public
A Kiwi.Signal that dispatches an event when the animation has come to the end of the animation and is going to play again.
onPlay
Kiwi.Signal
public
A Kiwi.Signal that dispatches an event when the animation has started playing.
onStop
Signal
public
A Kiwi.Signal that dispatches an event when the animation has stopped playing.
onUpdate
Kiwi.Signal
public
A Kiwi.Signal that dispatches an event when the animation has updated/changed frameIndexs.
reverse
Boolean
public
Whether the animation is to be played in reverse.
speed
Number
public
How long the each cell should stay on screen for. In seconds.