-
-
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
feat: Added children parameter to Component constructor #1525
Conversation
I think there a few components missing, SpriteAnimationComponent for example. Also we probably should do the same on the bridge packages |
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.
Missing docs, and I thought maybe Erick wanted to implement this (and might have already started) since he opened the issue so always good to discuss on the issue who's going to implementing it before doing it.
Other than that it looks good!
Right, so my thinking here is that we probably don't want to add Since I'm not exactly sure which components usually do or do not have children, I'll make a list and then you let me know which ones should get the parameter. |
I would say at least all |
|
The hitboxes and the TimerComponent doesn't need the field I'd say. |
Flame flare is kind obsolete because flame rive, so I would say that it can be omitted too |
The |
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.
Looks good! I left some minor comments. But overall this is quite useful.
I wonder if it would be valuable to also ad tests for each subclass of Component to check if children is correctly set.
The two approaches can be combined freely: the children specified within the | ||
constructor will be added first, and then any additional child components | ||
after. |
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.
Shall we also clarify, if the added children via children
are accesible (or not) from an lifecycle method such as onLoad
by reading children
?
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.
Added clarification.
game.add(component); | ||
await game.ready(); |
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.
ensureAdd?
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.
game.ready()
does the same, without the need to use a special extension.
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.
You do write one line less though
After checking again I think that |
Done. |
Description
This PR allows to pass the list of children as a parameter directly into the
Component
's constructor. This is an alternative to standardadd()
oraddAll()
methods.Checklist
fix:
,feat:
,docs:
etc).docs
and added dartdoc comments with///
.examples
.Breaking Change
Related Issues
Resolves #1522