-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add a loading screen to the web page #1
base: main
Are you sure you want to change the base?
Conversation
This is pretty neat, I had done loading screens within the game while assets are loading, but I hadn't thought about prior to the game launching.
I've tried that and it didn't work for me in the past. Gonna try it out on your PR when I get a chance. Overall, I'm cool with this. I would maybe set the background to a darker color, maybe even black, and the font color to white. Ideally, it'd be cool if it matched the initial splash screen in the game But, waiting for an image like that to load kinda defeats the purpose, right? Might not be so bad as an .svg, but, I think that doesn't necessarily have to be part of this. |
Sure, I can try matching the other loading screen! If you keep having problems with |
ah @TimJentzsch I saw you closed this today. At some point in the past I had disabled a lot of my github notifications because it was blowing up my email and my phone and didn't opt back in until my work life balance was a bit more stable. I suspect this fell off my radar during that time :( I'm not sure when I'll continue working on this game, but if you're cool with it I can reopen this and merge your PR. If not, that's cool too. Again, sorry about that 🙏 |
Not your fault, it was mine! |
Ok, maybe it won't be so easy:
|
This PR adds a loading screen to the web page.
Because the WASM binary is quite big, it can take a long time for the game to load. In this time, the user just sees a black/white screen and might be confused why nothing is happening.
This PR adds a (very simple) loading screen to indicate that something is happening. It could be expanded arbitrarily in the future, if needed.
It currently looks like this:

The three dots of the loading indicator are animated.
How it works
import("./bevy_game.wasm").then(...)
.div
for the loading screen was added inside thebody
.loading-screen.mjs
script implements the loading screen:canvas
element to be created. This indicates that the game has finished loading.How to test it
I created the
wasm
folder which contains everything needed to run the game on the web.Personally I use
cargo bavy run --wasm
(viacargo-bavy
) to run the changes locally.Alternatively, you can do the following:
assets
folder into thewasm
folder.wasm32-unknown-unknown
target in release mode.wasm
folder. They should be namedbevy_game.js
andbevy_game.wasm
(note that these are different names than before).wasm
folder on a webserver.In Firefox, you can turn on throttling in the network tab to see the loading screen. In Chrome it should work in a similar way.
TODO