Feel free to fix/add documentation to the wiki

Programming Guide

The cocos2d Programming Guide provides in-depth documentation for writing applications that use cocos2d. Many topics described here reference the cocos2d API reference, provided separately.

If this is your first time reading about cocos2d, we suggest you start at Writing a cocos2d application.

Scope

This documentation is valid for v0.99.x If you find any errors, please, either edit the wiki or send an email to the forum. Thanks.

Starting an empty project

cocos2d v0.99 comes with 3 Xcode templates

  • a cocos2d stand alone template
  • a cocos2d + box2d template
  • a cocos2d + chipmunk template

To install the templates, you should do:

$ cd cocos2d-iphone
$ ./install_template.sh

Once you have installed the templates, you can start a new project from Xcode:

  1. Open Xcode
  2. File → New Project
  3. Choose any cocos2d template

Writing a cocos2d application

Hello World

A basic example that displays Hello World on the screen.

Hello Actions

A basic example that teaches how to use actions.

Hello Events

A basic example that teaches how to use the accelerometer and the touches.

Where to Next ?

The examples presented in this chapter should have given you enough information to get started writing simple arcade and point-and-click-based games.

The remainder of this programming guide goes into quite technical detail regarding some of cocos2d's features. While getting started, it's recommended that you skim the beginning of each chapter but not attempt to read through the entire guide from start to finish.

To achieve optimal performance in your 2D applications you'll need to work with OpenGL directly. The canonical reference for OpenGL ES 1.1 is http://www.khronos.org/opengles/1_X/

There are numerous examples of cocos2d applications in the tests/ directory of the source distributions. Keep checking http://www.cocos2d-iphone.org/ for more examples and tutorials as they are written.

Basic Concepts

Actions, Transformations and Effects

Labels and Fonts

Tiled maps

Integrating cocos2d with Social Networks

Best Practices

Also, don't forget to read the cocos2d for iPhone best practices

Sample Games

Finally you can download/buy some open-source / commercial cocos2d for iPhone games