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.position,
      frame.size,
    );
    key += '${frame.path}${frame.position.x}${frame.position.y}';
    spriteList.add(sprite);
  }

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

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