You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I've been experimenting with Bevy and Wasm and have been trying to find a way to "close" a bevy app without needing to refresh the page. I wanted to do this because in a hypothetical scenario I might want to make a blog post showing different iterations of the same game, but I also don't want to bog down the reader's device with multiple Bevy Apps all running and doing stuff at the same time. The desire to find a solution to this despite not having anything in a presentable state burns within me.
What I attempted to do was have a run_game function which would create the App, and a stop_game function which would set a Mutex<bool> telling a system to EventWriter<AppExit>.send(AppExit::Success). And after I thought to myself how cleaver I was to figure that out, it didn't work!
So would it be possible for this function to be made to be able to return after an AppExit::Success, or is there another solution to this? And even if this did return properly, would it even be possible afterwards to call the run_game function to start everything up again?
Alternative solution
I do also understand that having a Bevy App in the middle of an article may not be the best experience in some cases (for instance, someone might use the scroll wheel and accidentally scroll away from the game they're playing), so one option would be to ditch having games in the middle of the page and just have a separate link to it on it's own page where that's the only thing on it, allowing readers to open and close the tabs with the games as they please. I assume this would work fine, but that's no fun! I want to be cool and have it in the middle of the page whether it's a good idea or not!
Edit: I guess this could have also maybe been made as a feature request instead of a question/discussion, but I'm bad at knowing what the correct thing to do is sometimes.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello! I've been experimenting with Bevy and Wasm and have been trying to find a way to "close" a bevy app without needing to refresh the page. I wanted to do this because in a hypothetical scenario I might want to make a blog post showing different iterations of the same game, but I also don't want to bog down the reader's device with multiple Bevy Apps all running and doing stuff at the same time. The desire to find a solution to this despite not having anything in a presentable state burns within me.
What I attempted to do was have a run_game function which would create the App, and a stop_game function which would set a
Mutex<bool>
telling a system toEventWriter<AppExit>.send(AppExit::Success)
. And after I thought to myself how cleaver I was to figure that out, it didn't work!So would it be possible for this function to be made to be able to return after an
AppExit::Success
, or is there another solution to this? And even if this did return properly, would it even be possible afterwards to call the run_game function to start everything up again?Alternative solution
I do also understand that having a Bevy App in the middle of an article may not be the best experience in some cases (for instance, someone might use the scroll wheel and accidentally scroll away from the game they're playing), so one option would be to ditch having games in the middle of the page and just have a separate link to it on it's own page where that's the only thing on it, allowing readers to open and close the tabs with the games as they please. I assume this would work fine, but that's no fun! I want to be cool and have it in the middle of the page whether it's a good idea or not!
Edit: I guess this could have also maybe been made as a feature request instead of a question/discussion, but I'm bad at knowing what the correct thing to do is sometimes.
Beta Was this translation helpful? Give feedback.
All reactions