Texture atlas and animations

Texture atlas and animations
0.0 0


i have a doubt about texture atlas. I would like to lower gpu memory requirements by using texture atlas,
but what about animations?
Suppose you have an animation composed of 3 sprites 1.png, 2.png and 3.png, with every sprite having the same width/height (that is, they
are WxH images RGB8888).
Suppose now that 1.png contain an object whose bounding box is smaller then WxH (the rest of the image is completely transparent), so is for 2.png and so for 3.png.
This is a common situation, since in this way i can easily draw the sprites on screen at the same (x,y) coordinate and obtain the right
What about texture atlas?
Is there a tool that does support this form of padding automatically? Does cocos2d-x support this form of padding?
Thank you!


do you mean there is a lot of empty space in some frames of your animation?

most atlas packers that ive seen will crop white-space.
http://www.codeandweb.com/texturepacker - certainly does.

it normally puts in an “offset” position which gets loaded by cocos2d and put in the spriteframes, that will move it back a certain amount to compensate for the cropping.


you can try PicOpt at http://sbcgamesdev.blogspot.cz/2012/10/sprite-atlas-tool-part-i-creating-atlas.html

It is free and you can create and export simple animations with it too. It also saves the offset so free space around the sprite is trimmed. Additionally you can add any number of your custom properties to sprites (like some offsets for example for gun barrel to know where the bullet should appear, various pivots, …)

Second article on the blog describes the data outputs.