Game Development Reference
memory becomes significant if you have several such images and you load them each
into individual textures.
That's where the texture atlas comes in. It's simply an image that is already aligned to a
power-of-two dimension and contains multiple images. Each image contained in the
texture atlas has a sprite frame that defines the rectangle area where the image is within
the texture atlas. In other words, a sprite frame is a CGRect structure that defines
which part of the texture atlas should be used as the sprite's image. These sprite frames
are saved in a separate .plist file so that cocos2d can render very specific images
from a large texture atlas texture.
Packing images into a texture atlas and noting the rectangular sprite frames they oc-
cupy would be a monumental task if it weren't for TexturePacker, a 2D sprite-packing
tool (shown in Figure 6-4 ). The TexturePacker app is available in both free and paid
versions and can be downloaded from www.texturepacker.com .
Figure 6-4 . TexturePacker with the ship's animation frames already packed into a texture atlas