mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 03:15:43 +08:00
Adding more PR suggestions
This commit is contained in:
committed by
Erick (CptBlackPixel)
parent
7776aec987
commit
10a7a89faa
@ -55,7 +55,7 @@ import 'package:flame/components/events/gestures.dart';
|
|||||||
|
|
||||||
class TapeableComponent extends PositionComponent with Tapeable {
|
class TapeableComponent extends PositionComponent with Tapeable {
|
||||||
|
|
||||||
// update, render ommited
|
// update and render omitted
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onTapUp(TapUpDetails details) {
|
void onTapUp(TapUpDetails details) {
|
||||||
|
|||||||
@ -66,6 +66,9 @@ abstract class Game {
|
|||||||
|
|
||||||
// Called when the Game widget is attached
|
// Called when the Game widget is attached
|
||||||
void onAttach() {
|
void onAttach() {
|
||||||
|
if (_gestureRecognizer != null) {
|
||||||
|
Flame.util.removeGestureRecognizer(_gestureRecognizer);
|
||||||
|
}
|
||||||
_gestureRecognizer = _createTapGestureRecognizer();
|
_gestureRecognizer = _createTapGestureRecognizer();
|
||||||
Flame.util.addGestureRecognizer(_gestureRecognizer);
|
Flame.util.addGestureRecognizer(_gestureRecognizer);
|
||||||
}
|
}
|
||||||
@ -106,20 +109,14 @@ abstract class BaseGame extends Game {
|
|||||||
/// List of deltas used in debug mode to calculate FPS
|
/// List of deltas used in debug mode to calculate FPS
|
||||||
final List<double> _dts = [];
|
final List<double> _dts = [];
|
||||||
|
|
||||||
bool _checkTapOverlap(Tapeable c, Offset o) {
|
bool _checkTapOverlap(Tapeable c, Offset o) => c.toRect().contains(o);
|
||||||
final pointRect = Rect.fromLTWH(o.dx, o.dy, 1, 1);
|
|
||||||
|
|
||||||
return c.toRect().overlaps(pointRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterable<Tapeable> get _tapeableComponents =>
|
Iterable<Tapeable> get _tapeableComponents =>
|
||||||
components.where((c) => c is Tapeable).cast();
|
components.where((c) => c is Tapeable).cast();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onTapCancel() {
|
void onTapCancel() {
|
||||||
_tapeableComponents.forEach((c) {
|
_tapeableComponents.forEach((c) => c.onTapCancel());
|
||||||
c.onTapCancel();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user