mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 20:36:31 +08:00
fix: renderChain should allow open-ended chain drawing (#1804)
This commit is contained in:
committed by
GitHub
parent
e53b6337b9
commit
60daa196a8
@ -125,8 +125,7 @@ abstract class BodyComponent<T extends Forge2DGame> extends Component
|
||||
}
|
||||
|
||||
void renderChain(Canvas canvas, List<Offset> points) {
|
||||
final path = Path()..addPolygon(points, true);
|
||||
canvas.drawPath(path, paint);
|
||||
canvas.drawPoints(PointMode.polygon, points, paint);
|
||||
}
|
||||
|
||||
void _renderCircle(Canvas canvas, Fixture fixture) {
|
||||
|
||||
@ -117,7 +117,7 @@ void main() {
|
||||
);
|
||||
|
||||
flameTester.testGameWidget(
|
||||
'a ChainShape',
|
||||
'an open ChainShape',
|
||||
setUp: (game, tester) async {
|
||||
final body = game.world.createBody(BodyDef());
|
||||
final shape = ChainShape()
|
||||
@ -140,7 +140,36 @@ void main() {
|
||||
verify: (game, tester) async {
|
||||
await expectLater(
|
||||
find.byGame<Forge2DGame>(),
|
||||
matchesGoldenFile(goldenPath('chain_shape')),
|
||||
matchesGoldenFile(goldenPath('chain_shape_open')),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
flameTester.testGameWidget(
|
||||
'a closed ChainShape',
|
||||
setUp: (game, tester) async {
|
||||
final body = game.world.createBody(BodyDef());
|
||||
final shape = ChainShape()
|
||||
..createLoop(
|
||||
[
|
||||
Vector2.zero(),
|
||||
Vector2.all(10),
|
||||
Vector2(10, 0),
|
||||
],
|
||||
);
|
||||
body.createFixture(FixtureDef(shape));
|
||||
|
||||
final component = _TestBodyComponent()
|
||||
..body = body
|
||||
..paint = testPaint;
|
||||
await game.add(component);
|
||||
|
||||
game.camera.followVector2(Vector2.zero());
|
||||
},
|
||||
verify: (game, tester) async {
|
||||
await expectLater(
|
||||
find.byGame<Forge2DGame>(),
|
||||
matchesGoldenFile(goldenPath('chain_shape_closed')),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Reference in New Issue
Block a user