SpriteAnimation.variableSpriteList constructor

SpriteAnimation.variableSpriteList(
  1. List<Sprite> sprites, {
  2. required List<double> stepTimes,
  3. bool loop = true,
})

Create animation from a list of sprites each having its own duration provided in the stepTimes list.

Implementation

factory SpriteAnimation.variableSpriteList(
  List<Sprite> sprites, {
  required List<double> stepTimes,
  bool loop = true,
}) {
  assert(
    stepTimes.length == sprites.length,
    'Lengths of stepTimes and sprites lists must be equal',
  );
  return SpriteAnimation(
    [
      for (var i = 0; i < sprites.length; i++)
        SpriteAnimationFrame(sprites[i], stepTimes[i]),
    ],
    loop: loop,
  );
}