fix: placed plunger correctly

pull/145/head
RuiAlonso 4 years ago
parent 659a872147
commit 344191c08f

@ -14,7 +14,9 @@ class Plunger extends BodyComponent with KeyboardHandler, InitialPosition {
/// {@macro plunger} /// {@macro plunger}
Plunger({ Plunger({
required this.compressionDistance, required this.compressionDistance,
}) : super(priority: 5); // TODO(ruimiguel): set to priority +1 over LaunchRamp once all priorities
// are fixed.
}) : super(priority: 0);
/// Distance the plunger can lower. /// Distance the plunger can lower.
final double compressionDistance; final double compressionDistance;
@ -112,7 +114,7 @@ class Plunger extends BodyComponent with KeyboardHandler, InitialPosition {
size: Vector2(5.5, 40), size: Vector2(5.5, 40),
anchor: Anchor.center, anchor: Anchor.center,
position: Vector2(2, 19), position: Vector2(2, 19),
angle: -0.035, angle: -0.033,
), ),
); );
} }

@ -21,6 +21,8 @@ class PinballGame extends Forge2DGame
final PinballAudio audio; final PinballAudio audio;
late Plunger plunger;
@override @override
void onAttach() { void onAttach() {
super.onAttach(); super.onAttach();
@ -70,8 +72,8 @@ class PinballGame extends Forge2DGame
} }
Future<void> _addPlunger() async { Future<void> _addPlunger() async {
final plunger = Plunger(compressionDistance: 29) plunger = Plunger(compressionDistance: 29)
..initialPosition = Vector2(38, -19); ..initialPosition = Vector2(38.2, -19);
await add(plunger); await add(plunger);
} }
@ -87,12 +89,6 @@ class PinballGame extends Forge2DGame
} }
Future<void> spawnBall() async { Future<void> spawnBall() async {
// TODO(alestiago): Remove once this logic is moved to controller.
var plunger = firstChild<Plunger>();
if (plunger == null) {
await add(plunger = Plunger(compressionDistance: 1));
}
final ball = ControlledBall.launch( final ball = ControlledBall.launch(
theme: theme, theme: theme,
)..initialPosition = Vector2( )..initialPosition = Vector2(

Loading…
Cancel
Save