fix: use both flippers on mobile (#318)

Co-authored-by: Tom Arra <tarra3@gmail.com>
pull/328/head
Jochum van der Ploeg 2 years ago committed by GitHub
parent ca9679ba1d
commit 82588602eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,7 +18,7 @@ class PinballGame extends PinballForge2DGame
FlameBloc,
HasKeyboardHandlerComponents,
Controls<_GameBallsController>,
TapDetector {
MultiTouchTapDetector {
PinballGame({
required this.characterTheme,
required this.audio,
@ -80,7 +80,7 @@ class PinballGame extends PinballForge2DGame
BoardSide? focusedBoardSide;
@override
void onTapDown(TapDownInfo info) {
void onTapDown(int pointerId, TapDownInfo info) {
if (info.raw.kind == PointerDeviceKind.touch) {
final rocket = descendants().whereType<RocketSpriteComponent>().first;
final bounds = rocket.topLeftPosition & rocket.size;
@ -98,19 +98,19 @@ class PinballGame extends PinballForge2DGame
}
}
super.onTapDown(info);
super.onTapDown(pointerId, info);
}
@override
void onTapUp(TapUpInfo info) {
void onTapUp(int pointerId, TapUpInfo info) {
_moveFlippersDown();
super.onTapUp(info);
super.onTapUp(pointerId, info);
}
@override
void onTapCancel() {
void onTapCancel(int pointerId) {
_moveFlippersDown();
super.onTapCancel();
super.onTapCancel(pointerId);
}
void _moveFlippersDown() {
@ -181,8 +181,8 @@ class DebugPinballGame extends PinballGame with FPSCounter {
}
@override
void onTapUp(TapUpInfo info) {
super.onTapUp(info);
void onTapUp(int pointerId, TapUpInfo info) {
super.onTapUp(pointerId, info);
if (info.raw.kind == PointerDeviceKind.mouse) {
final ball = ControlledBall.debug()

@ -323,7 +323,7 @@ void main() {
(flipper) => flipper.side == BoardSide.left,
);
game.onTapDown(tapDownEvent);
game.onTapDown(0, tapDownEvent);
expect(flippers.first.body.linearVelocity.y, isNegative);
});
@ -346,7 +346,7 @@ void main() {
(flipper) => flipper.side == BoardSide.right,
);
game.onTapDown(tapDownEvent);
game.onTapDown(0, tapDownEvent);
expect(flippers.first.body.linearVelocity.y, isNegative);
});
@ -369,14 +369,14 @@ void main() {
(flipper) => flipper.side == BoardSide.left,
);
game.onTapDown(tapDownEvent);
game.onTapDown(0, tapDownEvent);
expect(flippers.first.body.linearVelocity.y, isNegative);
final tapUpEvent = _MockTapUpInfo();
when(() => tapUpEvent.eventPosition).thenReturn(eventPosition);
game.onTapUp(tapUpEvent);
game.onTapUp(0, tapUpEvent);
await game.ready();
expect(flippers.first.body.linearVelocity.y, isPositive);
@ -400,11 +400,11 @@ void main() {
(flipper) => flipper.side == BoardSide.left,
);
game.onTapDown(tapDownEvent);
game.onTapDown(0, tapDownEvent);
expect(flippers.first.body.linearVelocity.y, isNegative);
game.onTapCancel();
game.onTapCancel(0);
expect(flippers.first.body.linearVelocity.y, isPositive);
});
@ -426,7 +426,7 @@ void main() {
final plunger = game.descendants().whereType<Plunger>().first;
game.onTapDown(tapDownEvent);
game.onTapDown(0, tapDownEvent);
game.update(1);
@ -452,7 +452,7 @@ void main() {
final previousBalls =
game.descendants().whereType<ControlledBall>().toList();
game.onTapUp(tapUpEvent);
game.onTapUp(0, tapUpEvent);
await game.ready();
expect(

Loading…
Cancel
Save