SpriteAnimation class

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

Constructors

SpriteAnimation(List<SpriteAnimationFrame> frames, {bool loop = true})
Creates an animation given a list of frames.
SpriteAnimation.empty()
Creates an empty animation
SpriteAnimation.fromAsepriteData(Image image, Map<String, dynamic> jsonData)
Automatically creates an Animation Object using animation data provided by the json file provided by Aseprite
SpriteAnimation.fromFrameData(Image image, SpriteAnimationData data)
Creates an SpriteAnimation based on its data.
SpriteAnimation.spriteList(List<Sprite> sprites, {required double stepTime, bool loop = true})
Creates an animation based on the parameters.
SpriteAnimation.variableSpriteList(List<Sprite> sprites, {required List<double> stepTimes, bool loop = true})

Properties

clock double
Current clock time (total time) of this animation, in seconds, since last frame.
getter/setter pair
currentFrame SpriteAnimationFrame
The current frame that should be displayed.
no setter
currentIndex int
Index of the current frame that should be displayed.
getter/setter pair
elapsed double
Total elapsed time of this animation, in seconds, since start or a reset.
getter/setter pair
frames List<SpriteAnimationFrame>
The frames that compose this animation.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isLastFrame bool
Returns whether the animation is on the last frame.
no setter
isSingleFrame bool
Returns whether the animation has only a single frame (and is, thus, a still image).
no setter
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.
getter/setter pair
onComplete OnCompleteSpriteAnimation?
Registered method to be triggered when the animation complete.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stepTime double
Sets a fixed step time to all frames.
no getter
variableStepTimes List<double>
Sets a different step time to each frame. The sizes of the arrays must match.
no getter

Methods

done() bool
getSprite() Sprite
Gets the current Sprite that should be shown.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Resets the animation, like it would just have been created.
reversed() SpriteAnimation
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

load(String src, SpriteAnimationData data, {Images? images}) Future<SpriteAnimation>
Takes a path of an image, a SpriteAnimationData and loads the sprite animation When the images is omitted, the global Flame.images is used