Our publisher asked us to improve the loading time of our game. Their dev has a good talk about its importance for players who run your game for the first time.
Defold packs all the game resources into a large package for the HTML5 platform, and all these files have to be downloaded before startup.
Defold has the Live Update feature, which we can use to split resources into two parts: all resources required for the first level of your game plus the rest of resources. The game can load these resources in the background (and from the same folder) while players are playing the first level.
I made an example project that loads resources from a .zip file using Live Update, and you can use it as a Defold library dependency:
In this project, the demo game loads the level 2 plus required resources from an external .zip file when you tap anywhere on it. I recommend you start loading these extra resources right after your game’s initialisation.
Now, about the issues that I faced while implementing this feature.
I didn’t manage to use the resource.store_archive() function as is. It loads the whole ZIP archive at once, but it also requires a manifest, and the new manifest requires a full restart of the game.
That’s why the demo project calls resource.store_resource() just to load resources without a manifest. Moreover, it extracts these resources from a single large ZIP file to avoid slow downloading hundreds of files one by one (I had to use the Miniz library for that).
Another issue is Live Update’s temporary storage of resources in .arcd/.arci files (in IndexedDB). The demo project deletes these files before the start of the game to handle the upgrade of the game. Otherwise, new resources can have the same filenames but different content. The collectionproxy.missing_resources doesn’t know about that, and it loads only new missing resources. The result of this total mess: returning players will not be able to play the game, i.e. it will crash.
To sum up, I would like:
To use resource.store_archive() to load missing resources from a .zip file and without the new manifest plus without the restart of the game.
To be able to disable Live Update’s temporary storage. This case doesn’t need it because a browser already caches all games files, and the game doesn’t use Live Update to upgrade itself.
Thanks a lot @aglitchman for sharing this very amazing and useful extenstion / project!
Finally we can use the functional of Live Update more often.
@Mathias_Westerdahl this is what I meant when I said download files locally in my recent thread (“downloading from local directory of HTML5 build”).
Also, I didn’t find it by searching the forum, I don’t know if this feature was discussed earlier, but will be nice to have the opportunity to see the progress of the downloading resources via Live Update.
Yet another game where we used the incredible capabilities of Defold’s Live Update is Fish Eat Fish , an HTML5 game. @notbadgun mainly developed the game, whereas my task was to optimize the framerate and reduce its size.
Thanks to the Live Update + ResZip, the game’s total size is only 4 MB! After the start, the game downloads the HD version of the graphics (10 MB, look at the “pie” progress bar in the corner) and applies it depending on hardware capabilities: