SpriteGroupComponent<T> constructor

SpriteGroupComponent<T>({
  1. Map<T, Sprite>? sprites,
  2. T? current,
  3. bool? autoResize,
  4. Paint? paint,
  5. Vector2? position,
  6. Vector2? size,
  7. Vector2? scale,
  8. double? angle,
  9. double nativeAngle = 0,
  10. Anchor? anchor,
  11. Iterable<Component>? children,
  12. int? priority,
  13. ComponentKey? key,
})

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

Implementation

SpriteGroupComponent({
  Map<T, Sprite>? sprites,
  T? current,
  bool? autoResize,
  Paint? paint,
  super.position,
  Vector2? 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,
      _sprites = sprites,
      _autoResize = autoResize ?? size == null,
      super(size: size ?? sprites?[current]?.srcSize) {
  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].
  this.size.addListener(_handleAutoResizeState);
}