PacktLib: Cocos2d for iPhone 1 Game Development Cookbook

Cocos2d for iPhone 1 Game Development Cookbook


About the Author

About the Reviewers




Drawing sprites

Coloring sprites

Animating sprites

Drawing OpenGL primitives

Playing video files

Grid, particle, and motion streak effects

Using Retina Display mode

1D and 2D Ease Actions

Rendering and texturing 3D shapes

Rendering a texture-filled polygon

Animating a texture-filled polygon

Swapping palettes using layers

Swapping palettes using CCTexture2DMutable

Using AWTextureFilter for blur and font shadows

Taking and using screenshots

Using CCParallaxNode

Lighting using glColorMask

User Input


Tap, hold, and drag input

Depth testing input

Creating buttons

Creating a directional pad

Creating an analog stick

Using the accelerometer for steering

Using the accelerometer for 3D rotation

Pinch zooming

Performing gestures

Files and Data


Reading PLIST data files

Reading JSON data files

Reading XML data files

Saving simple data using NSUserDefaults

Archiving objects into archive files

Mutating nested metadata

Saving data into a PLIST file

Saving data into an SQLite database

Saving data using Core Data



Box2D setup and debug drawing

Creating collision response routines

Using different shapes

Dragging and collision filtering

Manipulating physical properties

Applying impulses

Applying forces

Asynchronous body destruction

Using joints

Creating a vehicle

Character movement

Simulating bullets

Simulating and rendering a rope

Creating a top-down isometric game engine

Scenes and Menus


Switching scenes

Transitioning between scenes

Using CCLayerMultiplex

Using CCLabel

Using CCMenu

Creating shadowed menu labels

UIKit alert dialogs

Wrapping UIKit

Creating draggable menu windows

Creating a horizontal scrollable menu

Creating a vertical sliding menu grid

Creating a loading screen with an indicator

Creating a minimap



Playing sounds and music

Modifying audio properties

Fading sounds and music

Using audio in a game

Using positional audio in a game

Metering background music

Metering dialogue for animation

Streaming audio

Recording audio

Using the iPod music library

Creating a MIDI synthesizer

Speech recognition and text-to-speech

AI and Logic


Processing AI waypoints

Firing projectiles at moving targets

AI line of sight

AI flocking using Boids

A* pathfinding on a grid

A* pathfinding in a Box2D world

A* pathfinding on a TMX tilemap

A* pathfinding in a side-scroller

Running a Lua script

Dynamically loading Lua scripts

Using Lua for dialogue trees

Tips, Tools, and Ports


Accessing the Cocos2d-iPhone testbed

Packing textures using Zwoptex

Creating levels using Tiled

Creating levels using JSONWorldBuilder

Creating scenes with CocosBuilder

Using Cocos2d-X

Using Cocos3d

Releasing your app