-
-
Notifications
You must be signed in to change notification settings - Fork 895
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
Added a ButtonComponent #1146
Added a ButtonComponent #1146
Conversation
/// Note: You have to set the [button] in [onLoad] if you are not passing it in | ||
/// through the constructor. | ||
class ButtonComponent extends PositionComponent with Tappable { | ||
late final PositionComponent? button; |
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 this be non-nullable?
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.
No, because then we can't do an assertion on onMount
.
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.
Do we need an assertion though? If a variable is declared late final
and you use it before it is initialized, Dart will through an assertion error for you automatically.
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.
Those runtime errors are hard for the user to understand though, but maybe they are enough.
If we decide those are enough, then we need to change on all other PositionComponent
s that can be initialized like this too, so it is outside of the scope of this PR since it only follows the current structure.
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'm a bit confused on whats the difference then between ButtonComp and HudButtonComp? maybe something to explain on their docs in case people find the wrong one
|
Description
Since we have a
HudButtonComponent
I'm adding this one for consistency.If you haven't used the
HudButtonComponent
it is simply twoPositionComponent
s, one that shows when the button is pressed and one that shows otherwise.recording.mp4
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.