feat: add mobile touch controls

pull/232/head
Jochum van der Ploeg 3 years ago
parent f93f66656b
commit 9738f2def7
No known key found for this signature in database
GPG Key ID: E961B7B51589CA09

@ -81,11 +81,11 @@ class PinballGame extends Forge2DGame
@override
void onTapDown(TapDownInfo info) {
if (info.raw.kind == PointerDeviceKind.touch) {
final rocket = descendants().whereType<RocketSpriteComponent>().first;
final rocket = children.whereType<RocketSpriteComponent>().first;
final bounds = rocket.topLeftPosition & rocket.size;
if (bounds.contains(info.eventPosition.game.toOffset())) {
descendants().whereType<Plunger>().first.pull();
children.whereType<Plunger>().first.pull();
} else {
final leftSide = info.eventPosition.widget.x < canvasSize.x / 2;
boardSideActive = leftSide ? BoardSide.left : BoardSide.right;
@ -108,7 +108,7 @@ class PinballGame extends Forge2DGame
final bounds = rocket.topLeftPosition & rocket.size;
if (bounds.contains(info.eventPosition.game.toOffset())) {
descendants().whereType<Plunger>().first.release();
children.whereType<Plunger>().first.release();
} else {
_moveFlippersDown();
}
@ -117,7 +117,7 @@ class PinballGame extends Forge2DGame
@override
void onTapCancel() {
descendants().whereType<Plunger>().first.release();
children.whereType<Plunger>().first.release();
_moveFlippersDown();
super.onTapCancel();

Loading…
Cancel
Save