SpriteAnimationGroupComponent<T> constructor

SpriteAnimationGroupComponent<T>({
  1. Map<T, SpriteAnimation>? animations,
  2. T? current,
  3. bool? autoResize,
  4. bool playing = true,
  5. Map<T, bool> removeOnFinish = const {},
  6. bool autoResetTicker = true,
  7. Paint? paint,
  8. Vector2? position,
  9. Vector2? size,
  10. Vector2? scale,
  11. double? angle,
  12. double nativeAngle = 0,
  13. Anchor? anchor,
  14. Iterable<Component>? children,
  15. int? priority,
  16. ComponentKey? key,
})

Creates a component with an empty animation which can be set later

Implementation

SpriteAnimationGroupComponent({
  Map<T, SpriteAnimation>? animations,
  T? current,
  bool? autoResize,
  this.playing = true,
  this.removeOnFinish = const {},
  this.autoResetTicker = true,
  Paint? paint,
  super.position,
  super.size,
  super.scale,
  super.angle,
  super.nativeAngle,
  super.anchor,
  super.children,
  super.priority,
  super.key,
}) : assert(
       (size == null) == (autoResize ?? size == null),
       '''If size is set, autoResize should be false or size should be null when autoResize is true.''',
     ),
     _current = current,
     _animations = animations,
     _autoResize = autoResize ?? size == null,
     _animationTickers = animations != null
         ? Map.fromEntries(
             animations.entries
                 .map((e) => MapEntry(e.key, e.value.createTicker()))
                 .toList(),
           )
         : null {
  if (paint != null) {
    this.paint = paint;
  }

  /// Register a listener to differentiate between size modification done by
  /// external calls v/s the ones done by [_resizeToSprite].
  size.addListener(_handleAutoResizeState);
  _resizeToSprite();
}