Friday, 4 May 2012

TexturePacker to the rescue!

I found that in the past, during the development with my apps, a lot of time were spent working on the images/graphic. With 4 set of files - iPhone, iPhone Retina, iPad and the new iPad Retina, it's very painful as every time I change sometime or made a mistake, I have to repeat at least 4 times. Also, as there were so many individual files, managing them was really a nightmare as I have to make sure the correct image file been placed in the right directory...

After I followed a few of Ray Wenderlich's tutorials, I decided to give Texture Packer a try and found that it really saved me lots of time.

First of all, with the scripting capability, it automatically checks and packs all the relevant image files into as many sprite sheets as required (I split it into 2 for each device to make it smaller)

Secondly, if you use the compressed PVR format (.pvr.ccz), using Cocos2D as example, there's only 1 sprite file to worry and it's much faster to load and compact in size.

Plus with the scale/autosd feature, I can half the number of images - only the Retina version is required - as Texture Packer can automatically scale it down for me. And this is the best part I like.

A few other things I learned during testing with TextPacker to share with you:

1. If you get this error saying "cocos2d: TexturePVR: Error uploading compressed texture level: 0 . glError: 0x0501", that might be due to your sprite file sizes were too big. Suggest to split it into 2 or 3 more smaller files.

2. It's very easy to get file sizes over the 2048x2048 default for iPad/iPad Retina ones. So better adjust it in the script to allow 4096x4096 as width/height.

3. To use script to run TextPacker, you have to setup another Target. Once that's done, if you have to add files to your project, make sure you "tick" the check box for your project at the bottom window when Xcode asked you would you like to copy the file(s) over. I had some trouble with some font files which I forgot to tick the check box, and no matter how I change the code it just won't use the new font. Took me a long time to figure out it's because of that.

Hope you find these information helpful, and join the club to enjoy the convenience this handy tool could bring to you!

No comments:

Post a Comment