diff --git a/lib/game/pinball_game.dart b/lib/game/pinball_game.dart index 145e70126..d6b43702a 100644 --- a/lib/game/pinball_game.dart +++ b/lib/game/pinball_game.dart @@ -159,7 +159,7 @@ class PinballGame extends Forge2DGame final bounds = rocket.topLeftPosition & rocket.size; final tappedRocket = - bounds.contains(info.eventPosition.global.toOffset()); + bounds.contains(screenToWorld(info.eventPosition.widget).toOffset()); if (tappedRocket) { descendants() .whereType>() diff --git a/test/game/pinball_game_test.dart b/test/game/pinball_game_test.dart index c0d9ad4bc..1a4e58751 100644 --- a/test/game/pinball_game_test.dart +++ b/test/game/pinball_game_test.dart @@ -604,7 +604,9 @@ void main() { gameBloc.emit(gameBloc.state.copyWith(status: GameStatus.playing)); final eventPosition = _MockEventPosition(); - when(() => eventPosition.global).thenReturn(Vector2(40, 60)); + when(() => eventPosition.widget).thenReturn( + game.worldToScreen(Vector2(40, 60)), + ); final raw = _MockTapDownDetails(); when(() => raw.kind).thenReturn(PointerDeviceKind.touch); diff --git a/test/game/view/pinball_game_page_test.dart b/test/game/view/pinball_game_page_test.dart index c6501cd6a..01deeb0fc 100644 --- a/test/game/view/pinball_game_page_test.dart +++ b/test/game/view/pinball_game_page_test.dart @@ -301,25 +301,31 @@ void main() { expect(game.focusNode.hasFocus, isTrue); }); - testWidgets('mobile controls when the overlay is added', (tester) async { - await tester.pumpApp( - PinballGameView(game), - gameBloc: gameBloc, - startGameBloc: startGameBloc, - ); + testWidgets( + 'mobile controls when the overlay is added', + (tester) async { + await tester.pumpApp( + Material(child: PinballGameView(game)), + gameBloc: gameBloc, + startGameBloc: startGameBloc, + ); - game.overlays.add(PinballGame.mobileControlsOverlay); + game.overlays.add(PinballGame.mobileControlsOverlay); - await tester.pump(); + await tester.pump(); - expect(find.byType(MobileControls), findsOneWidget); - }); + expect( + game.overlays.isActive(PinballGame.mobileControlsOverlay), + isTrue, + ); + }, + ); testWidgets( 'ReplayButtonOverlay when the overlay is added', (tester) async { await tester.pumpApp( - PinballGameView(game), + Material(child: PinballGameView(game)), gameBloc: gameBloc, startGameBloc: startGameBloc, ); @@ -328,7 +334,10 @@ void main() { await tester.pump(); - expect(find.byType(ReplayButtonOverlay), findsOneWidget); + expect( + game.overlays.isActive(PinballGame.replayButtonOverlay), + isTrue, + ); }, );