1

I am making a game with a large number of sprite sheets in cocos2d-x. There are too many characters and effects, and each of them use a sequence of frames. The apk file is larger than 400mb. So I have to compress those images.

In fact, each frame in a sequence only has a little difference compares with others. So I wonder if there is a tool to compress a sequence of frames instead of just putting them into a sprite sheet? (Armature animation can help but the effects cannot be regarded as an armature.)

For example, there is an effect including 10 png files and the size of each file is 1mb. If I use TexturePacker to make them into a sprite sheet, I will have a big png file of 8mb and a plist file of 100kb. The total size is 8.1mb. But if I can compress them using the differences between frames, maybe I will get a png file of 1mb and 9 files of 100kb for reproducing the other 9 png files during loading. This method only requires 1.9mb size in disk. And if I can convert them to pvrtc format, the memory required in runtime can also be reduced.

By the way, I am now trying to convert .bmp to .pvr during game loading. Is there any lib for converting to pvr?

Thanks! :)

wayne
  • 101
  • 1
  • 8
  • 1
    Since you're already using TP just change its output format to pvr.ccz and you get the smallest files without quality loss that load fast and consume less memory. Win-win-win. Load-time conversion is pretty pointless though, it's only going to aggravate users. – CodeSmile Sep 30 '14 at 09:25
  • You're right, @LearnCocos2D . But our apk file is too fat on disk, and thus we only got an A rank. My boss wants it rated as S. So I am trying to decrease the size on disk. – wayne Oct 08 '14 at 02:44

1 Answers1

1

If you have lots of textures to convert to pvr, i suggest you get PowerVR tools from www.imgtec.com. It comes with GUI and CLI variants. PVRTexToolCLI did the job for me , i scripted a massive conversion job. Free to download, free to use, you must register on their site.

I just tested it, it converts many formats to pvr (bmp and png included).

Before you go there (the massive batch job), i suggest you experiment with some variants. PVR is (generally) fat on disk, fast to load, and equivalent to other formats in RAM ... RAM requirements is essentially dictated by the number of pixels, and the amount of bits you encode for each pixel. You can get some interesting disk size with pvr, depending on the output format and number of bits you use ... but it may be lossy, and you could get artefacts that are visible. So experiment with limited sample before deciding to go full bore.

The first place I would look at, even before any conversion, is your animations. Since you are using TP, it can detect duplicate frames and alias N frames to a single frame on the texture. For example, my design team provide me all 'walk/stance' animations with 5 pictures, but 8 frames! The plist contains frame aliases for the missing textures. In all my stances, frame 8 is the same as frame 2, so the texture only contains frame 2, but the plist artificially produces a frame8 that crops the image of frame 2.

The other place i would look at is to use 16 bits. This will favour bundle size, memory requirement at runtime, and load speed. Use RGBA565 for textures with no transparency, or RGBA5551 for animations , for examples. Once again, try a few to make certain you get acceptable rendering.

have fun :)

YvesLeBorg
  • 9,070
  • 8
  • 35
  • 48
  • Thank you! I have tried that PowerVR tools. It's really helpful if I want to convert other formats to PVR. However, I am still unsatisfied with the output from TP. So I want to decrease the size on disk largely. I'm still trying to compress this sprite sheet and maybe uncompress them when users run the game at the first time. – wayne Oct 08 '14 at 02:57