-
-
Notifications
You must be signed in to change notification settings - Fork 905
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: Misalignment of the hittest area of PolygonHitbox #2930
Changes from 4 commits
f7a8145
5171749
f662016
c2388dd
257dc38
da02f2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:flame/components.dart'; | ||
import 'package:flame/geometry.dart'; | ||
Check notice on line 2 in packages/flame/test/geometry/polygon_component_test.dart GitHub Actions / analyzeThe import of 'package:flame/geometry.dart' is unnecessary because all of the used elements are also provided by the import of 'package:flame/components.dart'.
Check notice on line 2 in packages/flame/test/geometry/polygon_component_test.dart GitHub Actions / analyze-latestThe import of 'package:flame/geometry.dart' is unnecessary because all of the used elements are also provided by the import of 'package:flame/components.dart'.
|
||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('PolygonComponent', () { | ||
test('HitTest for PolygonComponent', () { | ||
final polygon = PolygonComponent( | ||
[ | ||
Vector2(50, 50), | ||
Vector2(50, 150), | ||
Vector2(150, 150), | ||
Vector2(150, 50), | ||
], | ||
); | ||
expect(polygon.containsLocalPoint(Vector2(75, 25)), isFalse); | ||
expect(polygon.containsLocalPoint(Vector2(75, 75)), isTrue); | ||
expect(polygon.containsLocalPoint(Vector2(75, 125)), isTrue); | ||
expect(polygon.containsLocalPoint(Vector2(25, 75)), isFalse); | ||
expect(polygon.containsLocalPoint(Vector2(125, 75)), isTrue); | ||
}); | ||
|
||
test('HitTest for PolygonComponent.relative', () { | ||
final polygon = PolygonComponent.relative( | ||
[ | ||
Vector2(-0.5, -0.5), | ||
Vector2(-0.5, 0.5), | ||
Vector2(0.5, 0.5), | ||
Vector2(0.5, -0.5), | ||
], | ||
parentSize: Vector2.all(200), | ||
); | ||
expect(polygon.containsLocalPoint(Vector2(75, 25)), isFalse); | ||
expect(polygon.containsLocalPoint(Vector2(75, 75)), isTrue); | ||
expect(polygon.containsLocalPoint(Vector2(75, 125)), isTrue); | ||
expect(polygon.containsLocalPoint(Vector2(25, 75)), isFalse); | ||
expect(polygon.containsLocalPoint(Vector2(125, 75)), isTrue); | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move this to shape_component_test where the other tests for this are?
There are some inconsistencies of which directories the tests live currently so it can be quite hard to find the correct place. 😅