What are the ways to make a game slimmer?

Hi,

I have a lot of images in my game’s resource folder and these adds a lot to the size of the final package.

Which techniques considered helpful to handle such an issues?

Regards.

Are you using a sprite sheet?

http://cocos2d-x.org/programmersguide/3/index.html#creating-a-sprite-from-a-sprite-sheet

Yes, all of small/medium size images are packed in sprite-sheets.

For solid background images or non-alpha images, you can use jpg to get more compression. The tradeoff is that they load slower, but the load time might be insignificant. Try it out.

For PNG images, you can try different qualities of images. e.g. png-8 vs png-24 to get a 66% size reduction if the quality of png-8 meets your requirements. Be sure to test compatibility of your assets on all devices you want to support.

Make sure that you are not including assets in a build that are not used. e.g. dont include iPad retina images inside of an Android build if the Android build wont use them :wink:
I prefer to segment assets by iOS Universal, Android and Windows Phone. There is definitely overlap, but you can have the ability to include platform specific assets only on the target platform.

Are your assets sized correctly? If you have a bunch of assets in a 2048x2048 sprite sheet, are the sizes of the individual images only as big as they need to be. Sometimes I will trim off 10% of the size of all assets in a sprite sheet to enable packing more sprites into the 2048x2048 sheet (or other size sheet that I want to keep a power of 2.

Or how does the game look with the same sprites scaled in the 2048x2048 sheet scaled to 1024x1024? If you are using the camera and a lot of zooming and scaling is going on, then there might be opportunities to reduce the size of some assets without a noticeable impact to the quality of your game play.

For some graphics that are not used much, such as an options scene background, consider not including high resolution images if the look is not a significant difference and you are willing to live with having such areas of your app look a little less pretty. e.g. maybe the background on iOS on retina devices looks the same on retina devices weather you use a 2x image or a 1x image. This depends on the detail of your image, edges of your images, etc.

What is a lot of images?
If the final packaged app it is under 50MB, then maybe you don’t have a size issue.

1 Like

File size of the iOS build is 69.4 MB

Is there any safe way to compress textures, so they will work on most of the devices?

Does someone use ImageMagick to make textures slimmer?

Try to use a tool to do lossless compression on your assets.

I use ImageOptim (Mac only) to achieve that. There is either a GUI app that you just have to drop all your assets on, or a command-line version, once installed, to compress all a folder: imageoptim -d .

For added points, build a system to automatically compress all your assets periodically, and have that off your mind.

You can also look into reducing binary size, which is platform dependant.

On Android for example, check what architecture you really need. At the moment, the 64 bits are not really necessary for most games, and having both armeabi and armeabi-v7a is redundant, as all armv7 devices are armv5 compatible (if you need that added speed, perhaps you don’t need armv5 compatibility …). On Android again, you might shave off a few Mb by tweaking your Android.mk and cocos Android.mk to remove modules you don’t use, or switch to static libraries instead of whole static libraries or shared libraries.

For iOS, you might want to check that you don’t have legacy architectures (though I think cocos takes care of that). Doing a separate iPhone and iPad apps might be an option too, so that you don’t have to have an universal app with both assets.

2 Likes

@Fradow thanks for that one!

A great way to reduce app size that a lot of developers adopt presently, is to host the resources on a server and download the neccessary device specific resources from the server when the app is first run. It needs a bit of setup but it means that any device for any platform will only ever need 1 set of images instead of several. This is hands down the best way to make the smallest app size IMO.

There are other simpler options, such as the ones Heyalda mentioned. You can use libraries such as zLib for compression. zLib is commonly used with PVR (which is used a lot on iOS). It’s got the file extension .pvr.ccz.

As for png-8 png-24, you’re mixing up pixel formats with compression there. Pixel formats just say how many bits per pixel are used, for example RGBA8888 is the standard - 32-bit. 8 bits per channel. If you use RGBA4444 then the texture is going to be a lot smaller in size but it’s using less colours. Some people say RGBA4444 for backgrounds etc. I think the visual reduction is too large but it really depends how detailed you’re sprites are.

A program like TexturePacker allows you to set the pixel format for your spritesheets before you export. It also has other options that can really help to reduce the size of your textures. And also like Heyalda mentioned. Try to reuse as many textures as possible.

3 Likes

I’ve considered this solution, but didn’t found any examples that show to implement such scenario in Cocos2d-x C++

Did someone managed to implement such assets handling already?

@Greenhouse I doubt you would find any examples, it’s the sort of thing that’s complex enough for studios to want to protect their source code/ implementations and not really something you’d find code snippets for online. Whether related to Cocos2D-x or not.

Also since there are so many combinations of server setups and languages it’s not exactly like a one solution for one problem type of thing. There could be many ways to implement it and unless someone did a lengthy blog post about their own implementation. You would need the know how and skills to do it yourself from scratch. Network programming is definitely an essential skill here. You need knowledge to setup a backend.

But with so many third party providers out there, it wouldn’t surprise me if someone has encapsulated this functionality in to an SDK of sorts, so it’s definitely worth having a look for on Google or something.

Let me know if you find anything.

I thought there was a class called AssetsManagerEx or something like that in Cocos2d-x for that purposes if I’m not wrong.

@slackmoehrle Can you confirm this please?

First I’ve seen of that, looks interesting though. The function names certainly seem to match a system like that.

do all android devices support PNG-8?