Animation<T extends Object> constructor
Animation<T extends Object> ({})
Implementation
Animation({
required List<AnimationData<T>> animations,
required super.position,
int index = 0,
this.speed = 1.0,
this.mode = AnimMode.loop,
bool reverse = false,
super.originX = 0.5,
super.originY = 0.5,
super.opacity = 255,
super.scale = 1.0,
super.rotation = 0,
}) : assert(animations.isNotEmpty, "you have to provide atleast 1 AnimationData"),
_animations = Map.fromEntries(animations.map((e) => MapEntry(e.name, e))),
_state = animations.first.name,
_reverse = reverse,
_direction = reverse ? -1 : 1,
_index = reverse ? animations.first.frames.length - 1 : index,
_timer = reverse ? (animations.first.frames.length - 1).toDouble() : index.toDouble(),
super(
texture: animations.first.frames[reverse ? animations.first.frames.length - 1 : index],
) {
assert(
reverse || (index >= 0 && index < animations.first.frames.length),
"initial index is out of bounds for the first animation",
);
}