Yesterday I spent some time optimizing the assets folder to utilize LibGDX’s TextureAtlas and Texture Packer features. These allow all the game’s texture assets to be split up into files (atlas files) so that we load a handful of assets instead of a whole bunch of assets. My original intent was to speed up load-time; starting the game takes about 10 seconds right now, which is not too far off in comparison to other mobile games but is something I am personally trying to reduce.
One effect this change did have was to make the game snappier. I didn’t think that was possible, really, but now that the game is only having to bind a dozen textures instead of over three dozen, there is a noticeable difference when going between levels and back to the level select screen.
The texture packing technique can only work for textures, though. Sound assets are all loaded individually, which means they need to be optimized. I’m trying to find a sweet spot in terms of bit depth and file size to ensure the sounds are pleasant but understandably less optimized than they would be for, say, a desktop game. There are some known issues with Android phones and loading sound assets, but I think I can find a decent workaround for this if I get a little more creative.
Converting the files to OGG format helped save a ton of space. What also helped was to reduce the quality ever so slightly of any asset that was less than a second long. I figured these shorter sounds would only see mild improvement from having a greater sound quality. All in all, I’m very happy with the approach so far: Original sound assets totaled 15.74MB, and the present post-conversion size has been reduced to just 1.46MB.
Testing this load time did show a significant reduction (6 seconds!) but I think I can do better. I’m going to repack the textures with a 2048×2048 texture size (which will theoretically cut the number of atlas files I have in half) and then also start the assetmanager as soon as feasibly possible on application init (instead of where it currently is, which is two screens from the main game). If it’s the first thing that starts, maybe it can get some assets loaded before the loading screen hits, and then the loading screen will only appear momentarily?
The final load time is 3.9 seconds. Whew!
So in summary:
- Reduce the bit depth and quality of sounds that are played very briefly
- Ensure your texture atlases are sized appropriately
The next step from here is to scrub the levels to ensure none of them start out completed and we are ready to ship!