feat: removed friction from SlingShot

pull/39/head
alestiago 4 years ago
parent 21867812ed
commit 5883f3eb42

@ -49,7 +49,8 @@ class SlingShot extends BodyComponent {
} }
final triangle = PolygonShape()..set(triangleVertices); final triangle = PolygonShape()..set(triangleVertices);
fixtures.add(FixtureDef(triangle)); final triangleFixture = FixtureDef(triangle)..friction = 0;
fixtures.add(triangleFixture);
final kicker = EdgeShape() final kicker = EdgeShape()
..set( ..set(
@ -57,7 +58,9 @@ class SlingShot extends BodyComponent {
triangleVertices.last, triangleVertices.last,
); );
// TODO(alestiago): Play with restitution value once game is bundled. // TODO(alestiago): Play with restitution value once game is bundled.
final kickerFixtureDef = FixtureDef(kicker)..restitution = 20.0; final kickerFixtureDef = FixtureDef(kicker)
..restitution = 20.0
..friction = 0;
fixtures.add(kickerFixtureDef); fixtures.add(kickerFixtureDef);
return fixtures; return fixtures;

@ -66,6 +66,17 @@ void main() {
expect((fixture.shape as PolygonShape).vertices.length, equals(3)); expect((fixture.shape as PolygonShape).vertices.length, equals(3));
}, },
); );
flameTester.test(
'has no friction',
(game) async {
final slingShot = SlingShot(position: Vector2.zero());
await game.ensureAdd(slingShot);
final fixture = slingShot.body.fixtures[0];
expect(fixture.friction, equals(0));
},
);
}); });
group('second fixture', () { group('second fixture', () {
@ -100,6 +111,17 @@ void main() {
expect(fixture.restitution, greaterThan(0)); expect(fixture.restitution, greaterThan(0));
}, },
); );
flameTester.test(
'has no friction',
(game) async {
final slingShot = SlingShot(position: Vector2.zero());
await game.ensureAdd(slingShot);
final fixture = slingShot.body.fixtures[1];
expect(fixture.friction, equals(0));
},
);
}); });
}); });
} }

Loading…
Cancel
Save