SpriteAnimationComponent constructor

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

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

Implementation

SpriteAnimationComponent({
  SpriteAnimation? animation,
  bool? autoResize,
  this.removeOnFinish = false,
  this.playing = 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.''',
      ),
      _autoResize = autoResize ?? size == null,
      _animationTicker = animation?.createTicker() {
  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();
}