Fix hitbox circle on flip (#1165)

This commit is contained in:
Lukas Klingsbo
2021-12-05 20:38:52 +01:00
committed by GitHub
parent bfcda073bb
commit c35fb46078
3 changed files with 5 additions and 4 deletions

View File

@ -39,13 +39,12 @@ class MyCollidable extends PositionComponent
position: position, position: position,
size: Vector2.all(100), size: Vector2.all(100),
anchor: Anchor.center, anchor: Anchor.center,
) { );
addHitbox(HitboxCircle());
}
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
addHitbox(HitboxCircle());
final center = gameRef.size / 2; final center = gameRef.size / 2;
velocity = (center - position)..scaleTo(150); velocity = (center - position)..scaleTo(150);
} }

View File

@ -10,6 +10,7 @@
- Fix `Parallax.load` with different loading times - Fix `Parallax.load` with different loading times
- Fix render order of components and add tests - Fix render order of components and add tests
- `isHud` renamed to `respectCamera` - `isHud` renamed to `respectCamera`
- Fix `HitboxCircle` when component is flipped
## [1.0.0-releasecandidate.18] ## [1.0.0-releasecandidate.18]
- Forcing portrait and landscape mode is now supported on web - Forcing portrait and landscape mode is now supported on web

View File

@ -43,7 +43,8 @@ class Circle extends Shape {
_scaledSize _scaledSize
..setFrom(size) ..setFrom(size)
..multiply(scale); ..multiply(scale);
return (min(_scaledSize.x, _scaledSize.y) / 2) * normalizedRadius; return (min(_scaledSize.x.abs(), _scaledSize.y.abs()) / 2) *
normalizedRadius;
} }
/// This render method doesn't rotate the canvas according to angle since a /// This render method doesn't rotate the canvas according to angle since a