Animation class

Represents an animation, that is, a list of sprites that change with time.

Constructors

Animation(List<Frame> frames, {bool loop = true})
Creates an animation given a list of frames.
Animation.empty()
Creates an empty animation
Animation.sequenced(String imagePath, int amount, {int amountPerRow, double textureX = 0.0, double textureY = 0.0, double textureWidth, double textureHeight, double stepTime = 0.1, bool loop = true})
Automatically creates a sequenced animation, that is, an animation based on a sprite sheet. [...]
Animation.spriteList(List<Sprite> sprites, {double stepTime, bool loop = true})
Creates an animation based on the parameters. [...]
Animation.variableSequenced(String imagePath, int amount, List<double> stepTimes, {int amountPerRow, double textureX = 0.0, double textureY = 0.0, double textureWidth, double textureHeight, bool loop = true})
Works just like Animation.sequenced, but it takes a list of variable stepTimes, associating each one with one frame in the sequence.

Properties

clock double
Current clock time (total time) of this animation, in seconds, since last frame. [...]
read / write
currentFrame Frame
The current frame that should be displayed.
read-only
currentIndex int
Index of the current frame that should be displayed.
read / write
elapsed double
Total elapsed time of this animation, in seconds, since start or a reset.
read / write
frames List<Frame>
The frames that compose this animation.
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
isLastFrame bool
Returns whether the animation is on the last frame.
read-only
isSingleFrame bool
Returns whether the animation has only a single frame (and is, thus, a still image).
read-only
loop bool
Whether the animation loops after the last sprite of the list, going back to the first, or keeps returning the last when done.
read / write
onCompleteAnimation OnCompleteAnimation
Registered method to be triggered when the animation complete.
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
stepTime double
Sets a fixed step time to all frames.
write-only
variableStepTimes List<double>
Sets a different step time to each frame. The sizes of the arrays must match.
write-only

Methods

done() bool
If loop is false, returns whether the animation is done (fixed in the last Sprite). [...]
getSprite() Sprite
Gets the current Sprite that should be shown. [...]
loaded() bool
Whether all sprites composing this animation are loaded.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
reset() → void
Resets the animation, like it would just have been created.
reversed() Animation
Returns a new Animation based on this animation, but with its frames in reversed order
toString() String
A string representation of this object. [...]
inherited
totalDuration() double
Computes the total duration of this animation (before it's done or repeats).
update(double dt) → void
Updates this animation, ticking the lifeTime by an amount dt (in seconds).

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited

Static Methods

fromAsepriteData(String imagePath, String dataPath) Future<Animation>
Automatically creates an Animation Object using animation data provided by the json file provided by Aseprite [...]