Tooling Around – Texture Packer

One of the first lessons I learnt about bettering the performance of your game is to make use of sprite sheets instead of referring to individual sprite/image files. What does that mean? Well, basically, you’re talking about two options – one, you take all the images and stuff as many you can into a single file and then draw from it; or two, you refer to every image file separately.

As it turns out, your graphics processor likes it better if you made it just pick and draw from as few files as possible, instead of making it run around to different memory locations each time. The lesser you refer to different files to draw from, the faster it is. Therefore, the answer to how-to-bundle-images-in-one-file is…. sprite sheets.

So now that you know the answer and how important it is, you come to a different question – How are YOU going to bundle all these images? How are you going to track where each sub-image is located within the larger picture (so to speak), and how do you optimize placements and memory. Luckily for us, TexturePacker comes to the rescue. This tool frees you from the nitty gritties of texture management, and you get this easy one-click method to generate updated graphic sheets. All you need to do is point the tool towards the folder that holds the graphics and it takes care of the rest. Depending on the middleware you use for your programming, the data file will be generated for use in your game. You just pick it from the dropdown list and it takes care of the rest.

But there was something about TexturePacker that I found very interesting. I had this problem of setting up different resolution sheets for HD and SD. So I ended up worrying about generating two sets of graphics, and creating two config files for the sprite sheets. And that’s what we did for Orion’s Gold. Closer to release though, I found that TexturePacker has this option to provide variations based on the resolutions you need. It manages the downscaling (or upscaling, if you’re into that) of the sprite sheet, with some minor additions to the settings. You want it at half the size? No problem! At 0.365 times the size, just as easy! The purists will probably butt in here, saying you can’t just downscale textures if you want pixel perfect imagery with absolute control. But for the vast majority of us, this does a fantastic job… Something you’d probably do manually anyway.

There are a few settings you can tweak depending on what you’d like to do. The obvious few like what sort of algorithm you’d like to use for scaling, if you’re doing that; the gaps between the different images in the spritesheet. And if you see an option that you don’t really understand, all you have to do is hover over it – within a few seconds, a help note pops up to tell you what it does. The tool is incredibly user friendly, and the developers very down to earth and helpful.

You should totally check this out, it will save you loads of time and effort – letting you focus on your game. TexturePacker is available at