Fixes launch by touching rocket

pull/505/head
Alvaro Almeida Freire Stivi 1 year ago
parent cf3b00c7d4
commit a35e6687d1
No known key found for this signature in database

@ -159,7 +159,7 @@ class PinballGame extends Forge2DGame
final bounds = rocket.topLeftPosition & rocket.size; final bounds = rocket.topLeftPosition & rocket.size;
final tappedRocket = final tappedRocket =
bounds.contains(info.eventPosition.global.toOffset()); bounds.contains(screenToWorld(info.eventPosition.widget).toOffset());
if (tappedRocket) { if (tappedRocket) {
descendants() descendants()
.whereType<FlameBlocProvider<PlungerCubit, PlungerState>>() .whereType<FlameBlocProvider<PlungerCubit, PlungerState>>()

@ -604,7 +604,9 @@ void main() {
gameBloc.emit(gameBloc.state.copyWith(status: GameStatus.playing)); gameBloc.emit(gameBloc.state.copyWith(status: GameStatus.playing));
final eventPosition = _MockEventPosition(); final eventPosition = _MockEventPosition();
when(() => eventPosition.global).thenReturn(Vector2(40, 60)); when(() => eventPosition.widget).thenReturn(
game.worldToScreen(Vector2(40, 60)),
);
final raw = _MockTapDownDetails(); final raw = _MockTapDownDetails();
when(() => raw.kind).thenReturn(PointerDeviceKind.touch); when(() => raw.kind).thenReturn(PointerDeviceKind.touch);

@ -301,9 +301,11 @@ void main() {
expect(game.focusNode.hasFocus, isTrue); expect(game.focusNode.hasFocus, isTrue);
}); });
testWidgets('mobile controls when the overlay is added', (tester) async { testWidgets(
'mobile controls when the overlay is added',
(tester) async {
await tester.pumpApp( await tester.pumpApp(
PinballGameView(game), Material(child: PinballGameView(game)),
gameBloc: gameBloc, gameBloc: gameBloc,
startGameBloc: startGameBloc, startGameBloc: startGameBloc,
); );
@ -312,14 +314,18 @@ void main() {
await tester.pump(); await tester.pump();
expect(find.byType(MobileControls), findsOneWidget); expect(
}); game.overlays.isActive(PinballGame.mobileControlsOverlay),
isTrue,
);
},
);
testWidgets( testWidgets(
'ReplayButtonOverlay when the overlay is added', 'ReplayButtonOverlay when the overlay is added',
(tester) async { (tester) async {
await tester.pumpApp( await tester.pumpApp(
PinballGameView(game), Material(child: PinballGameView(game)),
gameBloc: gameBloc, gameBloc: gameBloc,
startGameBloc: startGameBloc, startGameBloc: startGameBloc,
); );
@ -328,7 +334,10 @@ void main() {
await tester.pump(); await tester.pump();
expect(find.byType(ReplayButtonOverlay), findsOneWidget); expect(
game.overlays.isActive(PinballGame.replayButtonOverlay),
isTrue,
);
}, },
); );

Loading…
Cancel
Save