Skip to content
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

[embedded mod]Add a callback function to embeddedLaunch? #1074

Open
chengenzhao opened this issue Jun 30, 2021 · 2 comments
Open

[embedded mod]Add a callback function to embeddedLaunch? #1074

chengenzhao opened this issue Jun 30, 2021 · 2 comments
Assignees
Labels
type:new feature Adding a feature that isn't currently present

Comments

@chengenzhao
Copy link
Contributor

Please discuss the feature ideas on Gitter first. Then please describe the feature
Add a callback function to embeddedLaunch method
thus when fxgl game is fully launched, the callback function will be called
Because currently the fxgl game launching is async
so if we embed the fxgl pane into javafx pane, then this async process may cause concurrent conflicts
If we could have a callback function to this method
the conflicts will be easily avoided

Describe alternatives you've considered (optional)
Currently we use EngineService and make a flag which isFirstInit = true
then in the onGameReady method
we need to judge if it isFirstInit
if true then do the callback work and turn isFirstInit to false
not very clean code and hard to maintain

@chengenzhao chengenzhao added the type:new feature Adding a feature that isn't currently present label Jun 30, 2021
@chengenzhao chengenzhao changed the title Add a callback function to embeddedLaunch? [embedded mod]Add a callback function to embeddedLaunch? Jun 30, 2021
@AlmasB AlmasB self-assigned this Jul 16, 2021
@AlmasB
Copy link
Owner

AlmasB commented Jul 16, 2021

There are a few key moments when the callback can occur.

The code that needs to be repeatedly called after each game start should go into an EngineService::onGameReady. I believe this is not your use case since you are using isFirstInit. The code that needs to be called once per application after the main loop started should go into an EngineService::onMainLoopStarting.

This leaves us with one use case that is currently not covered: the moment after FXGL.* calls can be made, but before the game is ready. I think it would be beneficial for this callback to be called after FXGL.* calls are valid since the above use cases are already covered with current API.

@chengenzhao
Copy link
Contributor Author

Good Morning @AlmasB
We use this feature simply because the FXGL application has to start with JavaFX program
We have to start and cache it.
It is async start so we have to disable JavaFX components and wait it fully started then enable those components.
And when we enter the battle scene we will put FXGL pane into JavaFX container to display the game and remove it when the battle is over
so if Add embeddedShutdown to decouple fxgl instance from javafx instance is solved then we probably dont need this callback
We could start FXGL application when we need it and shut it down and restart again...

@AlmasB AlmasB added this to the FXGL 17 milestone Sep 21, 2021
@AlmasB AlmasB removed this from the FXGL 17 milestone Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:new feature Adding a feature that isn't currently present
Projects
None yet
Development

No branches or pull requests

2 participants