getSpriteAnimation static method

ControlledUpdateAnimation getSpriteAnimation(
  1. List<TileModelSprite> frames,
  2. double stepTime
)

Implementation

static ControlledUpdateAnimation getSpriteAnimation(
  List<TileModelSprite> frames,
  double stepTime,
) {
  String key = '';
  List<Sprite> spriteList = [];

  for (var frame in frames) {
    Sprite sprite = MapAssetsManager.getSprite(
      frame.path,
      frame.row,
      frame.column,
      frame.width,
      frame.height,
    );
    key += '${frame.path}${frame.row}${frame.column}';
    spriteList.add(sprite);
  }

  if (spriteAnimationCache.containsKey(key)) {
    return spriteAnimationCache[key]!;
  }

  return spriteAnimationCache[key] = ControlledUpdateAnimation.fromInstance(
    SpriteAnimation.spriteList(
      spriteList,
      stepTime: stepTime,
    ),
  );
}