From 10a7a89faa57142b429302f59aa7e40aebe64cd0 Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Tue, 10 Sep 2019 18:40:14 -0300 Subject: [PATCH] Adding more PR suggestions --- doc/input.md | 2 +- lib/game.dart | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/doc/input.md b/doc/input.md index 5fef17971..c3bb2347d 100644 --- a/doc/input.md +++ b/doc/input.md @@ -55,7 +55,7 @@ import 'package:flame/components/events/gestures.dart'; class TapeableComponent extends PositionComponent with Tapeable { - // update, render ommited + // update and render omitted @override void onTapUp(TapUpDetails details) { diff --git a/lib/game.dart b/lib/game.dart index fe21c7027..e5cab7f5a 100644 --- a/lib/game.dart +++ b/lib/game.dart @@ -66,6 +66,9 @@ abstract class Game { // Called when the Game widget is attached void onAttach() { + if (_gestureRecognizer != null) { + Flame.util.removeGestureRecognizer(_gestureRecognizer); + } _gestureRecognizer = _createTapGestureRecognizer(); Flame.util.addGestureRecognizer(_gestureRecognizer); } @@ -106,20 +109,14 @@ abstract class BaseGame extends Game { /// List of deltas used in debug mode to calculate FPS final List _dts = []; - bool _checkTapOverlap(Tapeable c, Offset o) { - final pointRect = Rect.fromLTWH(o.dx, o.dy, 1, 1); - - return c.toRect().overlaps(pointRect); - } + bool _checkTapOverlap(Tapeable c, Offset o) => c.toRect().contains(o); Iterable get _tapeableComponents => components.where((c) => c is Tapeable).cast(); @override void onTapCancel() { - _tapeableComponents.forEach((c) { - c.onTapCancel(); - }); + _tapeableComponents.forEach((c) => c.onTapCancel()); } @override