refactor: changed spawnBall initialPosition

pull/145/head
RuiAlonso 4 years ago
parent 3a1b432ce0
commit 5b0bcc0b20

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

Loading…
Cancel
Save