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 {
|
||||
|
||||
// update, render ommited
|
||||
// update and render omitted
|
||||
|
||||
@override
|
||||
void onTapUp(TapUpDetails details) {
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user