Reducing Your Mobile Game Size

About a week ago I forked over $99 to Apple for their developer tools, which allowed me to finally put my game on my iPhone. Naturally the first thing I did was start Frontend, dump all my maps in the cook list, and package my game…but I was unnaturally surprised by the size of the final .ipa. It weighed in at a little over 500 megabytes.

For mobile games, app size is very important. In many places the maximum phone network file size is 50 MB; if your app is larger than that, consumers have to connect to a WiFi network to download and install. For many people this is more trouble than it’s worth (especially if the app is relatively unknown), so the smaller the final .ipa the better.

First big tip: at any time you can delete the directories \UDKGame\CookedIPhone and \Development\Intermediate to “restart” the development process. Why? When you move uncooked assets around, for example from a map to a separate package, UDK doesn’t automatically rebuild the cooked files unless assets have either been added or removed completely. It’s actually a good idea to delete these directories every time you repackage your game.

Secondly, if you have multiple maps, move any shared assets to a single package and add it as a startup package. This can be done by opening up DefaultEngine.ini and adding the line +Package=[PACKAGE NAME] under both [Engine.PackagesToAlwaysCook] and [Engine.StartupPackages]. For example, every single asset in my game Never End is in the package Never_End_MAssets, so I have added the line +Package=Never_End_MAssets to both sections. Why? It turns out that if you have multiple maps, each cooked map will hold a reference to the assets it needs if they are not loaded upon startup — this can bloat the size of the map files up to 20-fold.

Any sounds you have should be loaded at startup regardless of where they are used, otherwise they’ll be included in every level. However, music files should also have .mp3 counterparts in \UDKGame\Build\iPhone\Resources\Music. When the game is cooked, the massive .wav files for your game music will be replaced by these .mp3 files and greatly reduce the startup package size.

Another reason to put all your assets in a startup package: they’re guaranteed to load before the game even shows. If you don’t put your fonts in a startup package, UDK will only load the glyphs as they are needed by code: the result can be half-formed text, blurry text, or even invisible text. Sounds not loaded at startup will take longer to play the first time they are loaded, which can really throw off the gaming experience if they are large files.

Finally, think about how textures will look in the final game. I originally made each texture in my game either 512×512 or 1024×1024, but in most cases they’re displayed smaller than 128×128 even on Retina displays. UDK is also quite good at scaling up textures (don’t depend on it though), so in the rare cases that my textures were shown at larger sizes they still looked good. This is a 16-fold space reduction.

Following all these tips, I managed to get my uncompressed .ipa down to a mere 72 MB. The general rule is that the production .ipa will be about half this value, so I’m well under the 50 MB WiFi limit even after adding some final assets.

Advertisements

6 thoughts on “Reducing Your Mobile Game Size

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s