Game Development Reference
In-Depth Information
Figure 6-5 . The folder contents of the Assets folder
Another tip that makes handling image files easier is to put all image files that should
be packed into the same texture atlas in the same subfolder. In the case of the Sprites02
project, the Assets folder has a subfolder called GameArt that contains all the im-
age files that are packed into the game-art texture atlas.
TexturePacker simply adds new image files in that folder when you're refreshing the
texture atlas in TexturePacker, so you don't have to add individual images manually
anymore. TexturePacker will create one .tps (TexturePacker Save) file for each
folder.
Caution If you have an individual image file called bullet.png , the HD
version must be named bullet-hd.png , and in cocos2d you have to load
the file with the string @"bullet.png" .
A common mistake that happens when you move from individual images to a
texture atlas is to add images to the texture atlas that have the -hd prefix in
their filename. In that case, the resulting texture atlas for SD and HD versions
might be named bulletatlas.pvr.czz and bulletatlas-
hd.pvr.czz . But the images contained in the texture atlas, now called sprite
frames, will all have the name bullet-hd.png even in the SD texture atlas.
Thus, you'd have to change all references in cocos2d from @"bullet.png"
to @"bullet-hd.png" . To avoid this issue, for creating a texture atlas I re-
commend using HD version images without the -hd suffix in the filename.
Even worse would be to manually create two texture atlases, one for SD images
containing only image files without the -hd suffix and one for HD images con-
taining only image files with the -hd suffix. If you then loaded @"bul-
let.png" in cocos2d, it wouldn't be able to find the -hd image on Retina
devices. If you loaded @"bullet-hd.png" , the SD images wouldn't load.
That's because the distinction between SD and HD is done at the texture atlas
level; you will have a texture atlas with the -hd suffix and one without. The
names of the sprite frames inside a texture atlas must be identical for both SD
and HD texture atlases.
Creating a Texture Atlas with TexturePacker
Search Nedrilad ::




Custom Search