Animation<T extends Object> constructor

Animation<T extends Object>({
  1. required List<AnimationData<T>> animations,
  2. required Vec2 position,
  3. int index = 0,
  4. double speed = 1.0,
  5. AnimMode mode = AnimMode.loop,
  6. bool reverse = false,
  7. double originX = 0.5,
  8. double originY = 0.5,
  9. int opacity = 255,
  10. double scale = 1.0,
  11. double rotation = 0,
})

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",
  );
}