PositionComponent constructor

PositionComponent({
  1. Vector2? position,
  2. Vector2? size,
  3. Vector2? scale,
  4. double? angle,
  5. double nativeAngle = 0,
  6. Anchor? anchor,
  7. Iterable<Component>? children,
  8. int? priority,
  9. ComponentKey? key,
})

Implementation

PositionComponent({
  Vector2? position,
  Vector2? size,
  Vector2? scale,
  double? angle,
  this.nativeAngle = 0,
  Anchor? anchor,
  super.children,
  super.priority,
  super.key,
})  : transform = Transform2D(),
      _anchor = anchor ?? Anchor.topLeft,
      _size = NotifyingVector2.copy(size ?? Vector2.zero()) {
  decorator = Transform2DDecorator(transform);
  if (position != null) {
    transform.position = position;
  }
  if (angle != 0) {
    transform.angle = angle ?? 0;
  }
  if (scale != null) {
    transform.scale = scale;
  }
  _size.addListener(_onModifiedSizeOrAnchor);
  _onModifiedSizeOrAnchor();
}