SpriteAnimation.variableSpriteList constructor

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

Implementation

SpriteAnimation.variableSpriteList(
  List<Sprite> sprites, {
  required List<double> stepTimes,
  this.loop = true,
}) {
  if (sprites.isEmpty) {
    throw Exception('You must have at least one frame!');
  }
  if (stepTimes.length != sprites.length) {
    throw Exception('The length of stepTimes and sprites must be the same!');
  }

  frames = List.generate(
    sprites.length,
    (i) => SpriteAnimationFrame(sprites[i], stepTimes[i]),
    growable: false,
  );
}