RectangleHitbox.relative constructor

RectangleHitbox.relative(
  1. Vector2 relation, {
  2. required Vector2 parentSize,
  3. Vector2? position,
  4. double? angle,
  5. Anchor? anchor,
  6. bool isSolid = false,
  7. CollisionType collisionType = CollisionType.active,
})

With this constructor you define the RectangleHitbox in relation to the parentSize. For example having relation as of (0.8, 0.5) would create a rectangle that fills 80% of the width and 50% of the height of parentSize.

Implementation

RectangleHitbox.relative(
  super.relation, {
  required super.parentSize,
  super.position,
  super.angle,
  super.anchor,
  bool isSolid = false,
  CollisionType collisionType = CollisionType.active,
})  : shouldFillParent = false,
      super.relative(
        shrinkToBounds: true,
      ) {
  this.isSolid = isSolid;
  this.collisionType = collisionType;
}