Closed AlmasB closed 3 years ago
Hello @AlmasB ,
I have been playing around with the StateComponent API and looked through the Robot Platformer in FXGL-samples>Java>Advanced>Platformer
which makes use of it. I'd like to work on this and after a little more studying I will come back to you with an outline of what I want to write for this Wiki. This is also the first time I will be writing a Wiki but I will try to conform my writing to existing pages.
Thanks! Adam
Great stuff, thanks for letting me know!
On Wed, 10 Mar 2021, 6:37 pm Adam Bocco, notifications@github.com wrote:
Hello @AlmasB https://github.com/AlmasB ,
I have been playing around with the StateComponent API and looked through the Robot Platformer in FXGL-samples>Java>Advanced>Platformer which makes use of it. I'd like to work on this and after a little more studying I will come back to you with an outline of what I want to write for this Wiki. This is also the first time I will be writing a Wiki but I will try to conform my writing to existing pages.
Thanks! Adam
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AlmasB/FXGL/issues/981#issuecomment-795883604, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3NT5XRSNZYM5L3LP3BKQDTC6U4VANCNFSM4YXVEZBQ .
@AlmasB After some consideration I think this might be a good outline to go with:
The state component can be added to entities to provide an API that defines and manages entity states and their transitions to other states.
jumping
and standing
state component that changes the color view of a player entity depending on these 2 states.I had some questions while trying to learn this API. Are there any examples of making a subState hierarchy from entity states? Also I'm not sure if I should mention component injection.
Let me know what you think! Thanks, Adam Bocco
All looks good. One comment about the example: state API + physics is probably a bit complex, so I'd get rid of physics. Maybe start with a Component, in which the update does:
if () {}
else if () {}
else {}
This is a good use case that can be refactored into State API.
Or better still, if you can think of some AI maybe for your own game, where you'd need to use multiple states, e.g. Patrol, Attack, Flee, etc. Typically, a real example is much more illustrative rather than a contrived one.
Are there any examples of making a subState hierarchy from entity states?
Whilst the state machine that drives EntityState supports it, I believe I disabled hierarchies for EntityState (to keep it simple).
Also I'm not sure if I should mention component injection.
It's fine to omit it, as component injection is not unique to StateComponent
@AlmasB
What is the procedure for making a PR for a wiki? I have a draft of the wiki I'd like to get your input on. You can find it here.
Thanks! Adam Bocco
Just adding here to the issue is fine, makes it easy to edit. Once complete, I usually create a page and add author's name at the top. I'll copy your text below and provide feedback.
I've skimmed through it, looks really good. Many thanks.
Added here: https://github.com/AlmasB/FXGL/wiki/Entity-States-and-StateComponent-API-(FXGL-11)
This should include a brief explanation of how states work and how to use them