Adding more PR suggestions

This commit is contained in:
Erick Zanardo
2019-09-10 18:40:14 -03:00
committed by Erick (CptBlackPixel)
parent 7776aec987
commit 10a7a89faa
2 changed files with 6 additions and 9 deletions

View File

@ -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) {

View File

@ -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<double> _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<Tapeable> get _tapeableComponents =>
components.where((c) => c is Tapeable).cast();
@override
void onTapCancel() {
_tapeableComponents.forEach((c) {
c.onTapCancel();
});
_tapeableComponents.forEach((c) => c.onTapCancel());
}
@override