I am going to start work on a game that would likely have a lot of assets, including graphics and music, and I want to keep the initial download as lean as possible. So I figured I would only download what I need to start the game up-front and then load more assets as they are needed. I think I have a strategy for this but I don’t know if I may be missing a feature of Phaser or if there is a better strategy. So here is how I am figuring it would go:
- Start the game with a normal Preload scene that downloads what is absolutely needed to start the game.
- Keep a list of all of the asset paths in the game in-memory and also keep a list of the assets that are downloaded in the client. I would also need a list of assets needed for each scene/level.
- When I am needing to load in more assets, I call a generic scene which acts as a loading scene. I pass in a list of what I need to download into this scene as well as the name of the target scene I will want to start once I have these assets. The loading scene starts loading these assets in the preload() method, shows a progress bar, etc.
- Once the loading is done, add the downloaded assets to the downloaded asset list in memory and start the target scene.
- On any future trips into the target scene, the list of downloaded assets should tell me if the client has everything it needs to start the scene without loading anything else. This logic could probably be in my generic loading scene. Maybe this isn’t needed since I believe that Phaser is smart enough to not load again any assets it already has in cache so perhaps I can just go through the motions of downloading the required assets every time I am entering the target scene and Phaser will just skip them on subsequent loads.
Does this seem sound? Thanks!