Swapping palettes using layers

A vital tool in any game developer's repertoire is the ability to swap color palettes. From The Legend of Zelda on NES to Halo on the Xbox, palette swapping is a simple yet effective visual cue that can stretch a limited amount of art.

In the following example you learn how to palette swap using layers. We are using an animated baseball player for this example.

Swapping palettes using layers

Getting ready

Please refer to the project RecipeCollection01 for full working code of this recipe.

For this recipe you will need an image manipulation program. I recommend the free and easy to use GIMP.

How to do it...

The first thing we will do is draw the sprite ...

Get Cocos2d for iPhone 1 Game Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.