Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: RectangleHitbox should shrink to bounds #1596

Merged
merged 3 commits into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class RectangleHitbox extends RectangleComponent with ShapeHitbox {
parentSize: parentSize,
angle: angle,
anchor: anchor,
shrinkToBounds: true,
);

@override
Expand Down
12 changes: 10 additions & 2 deletions packages/flame/lib/src/geometry/rectangle_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ class RectangleComponent extends PolygonComponent {
/// [parentSize].
RectangleComponent.relative(
Vector2 relation, {
Vector2? position,
required Vector2 parentSize,
double angle = 0,
Vector2? position,
Vector2? scale,
double? angle = 0,
Anchor? anchor,
int? priority,
Paint? paint,
bool? shrinkToBounds,
}) : super.relative(
[
relation.clone(),
Expand All @@ -59,9 +63,13 @@ class RectangleComponent extends PolygonComponent {
Vector2(-relation.x, relation.y),
],
position: position,
scale: scale,
parentSize: parentSize,
angle: angle,
anchor: anchor,
priority: priority,
paint: paint,
shrinkToBounds: shrinkToBounds,
);

/// This factory will create a [RectangleComponent] from a positioned [Rect].
Expand Down