SpriteAnimation class
Represents a sprite animation, that is, a list of sprites that change with time.
Constructors
-
SpriteAnimation(List<
SpriteAnimationFrame> frames, {bool loop = true}) -
SpriteAnimation.fromAsepriteData(Image image, Map<
String, dynamic> jsonData) -
Automatically creates an Animation Object using animation data provided by
the json file provided by Aseprite.
factory
- SpriteAnimation.fromFrameData(Image image, SpriteAnimationData data)
-
Create animation from a single
image
that contains all frames.factory -
SpriteAnimation.spriteList(List<
Sprite> sprites, {required double stepTime, bool loop = true}) -
Create animation from a list of
sprites
all having the same transition timestepTime
.factory -
SpriteAnimation.variableSpriteList(List<
Sprite> sprites, {required List<double> stepTimes, bool loop = true}) -
Create animation from a list of
sprites
each having its own duration provided in thestepTimes
list.factory
Properties
- clock ↔ double
-
Current clock time (total time) of this animation, in seconds, since last
frame.
getter/setter pair
-
completed
→ Future<
void> -
A future that will complete when the animation completes.
no setter
- 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
- isFirstFrame → bool
-
Returns whether the animation is on the first frame.
no setter
- 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 ↔ (void Function()?)
-
Registered method to be triggered when the animation complete.
getter/setter pair
- onFrame ↔ (void Function(int currentIndex)?)
-
Registered method to be triggered when the animation frame updates.
getter/setter pair
- onStart ↔ (void Function()?)
-
Registered method to be triggered when the animation starts.
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
-
clone(
) → SpriteAnimation - Returns a new Animation equal to this one in definition, but each copy can be run independently.
-
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
-
setToLast(
) → void - Sets this animation to be on the last frame.
-
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.