-
-
Notifications
You must be signed in to change notification settings - Fork 899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Allow most basic and advanced gesture detectors together #1208
Conversation
void onTapUp(int id, TapUpInfo info) { | ||
super.onTapUp(id, info); | ||
final touchPoint = info.eventPosition.game; | ||
final handled = children.any((c) => c.shouldRemove); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting approach!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put a TODO on the onTap* that it should return whether any child handled the tap (returned false)
} | ||
|
||
@override | ||
void onDoubleTap() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like a very specific feature to showcase on this example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was here already, I just moved the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but we can always improve :P
WARNING: Both Advanced and Basic detectors detected. | ||
Advanced detectors will override basic detectors and the later will not receive events | ||
''', | ||
!(game is MultiTouchDragDetector && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have some tests for these new assertions?
|
||
@override | ||
Future<void> onLoad() async { | ||
await super.onLoad(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need this, if super's onLoad
is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was already there, I just moved the class.
But I can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, it has @mustCallSuper on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, the question then why must it, if the super doesn't do anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember, there was some reasoning behind it though. Do you remember @erickzanardo or @luanpotter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is some FlameGame and Component mixins do initialization onLoad. so if people don't call super, those are missed, causing bugs. Thus we added the annoation so people would not make such mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description
Most gesture detectors work together now, except for the
PanDetector
orScaleDetector
together with theMultiTouchDragDetector
. Maybe even theScaleDetector
will work with theMultiTouchDragDetector
, will have to try.Also simplified the example game a little bit.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
) and updated/added examples indoc/examples
.flutter format
and theflutter analyze
does not report any problems.[next]
inCHANGELOG.md
.Draft
status, by clicking on theReady for review
button in this PR.Breaking Change
Does your PR require Flame users to manually update their apps to accommodate your change?
CHANGELOG.md
).Related Issues
Replace this paragraph with a list of issues related to this PR from the issue database. Indicate, which of these issues are resolved or fixed by this PR.