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);
fixtures.add(FixtureDef(triangle));
final triangleFixture = FixtureDef(triangle)..friction = 0;
fixtures.add(triangleFixture);
final kicker = EdgeShape()
..set(
@ -57,7 +58,9 @@ class SlingShot extends BodyComponent {
triangleVertices.last,
);
// 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);
return fixtures;

@ -66,6 +66,17 @@ void main() {
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', () {
@ -100,6 +111,17 @@ void main() {
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