cocos2d for iPhone is a framework for building 2D games, demos, and other graphical/interactive applications. It is based on the cocos2d design: it uses the same concepts, but instead of using python it uses objective-c.
cocos2d for iPhone is:
- Easy to use: it uses a familiar API, and comes with lots of examples
- Fast: it uses the OpenGL ES best practices and optimized data structures
- Flexible: it is easy to extend, easy to integrate with 3rd party libraries
- Free: is open source, compatible both with closed and open source games
- Community supported: cocos2d has an active, big and friendly community (forum, IRC)
- AppStore approved: More than 2500 AppStore games already use it, including many best seller games.
cocos2d for iPhone supports: iPod Touch, iPhone, iPad and OS X
第一步: 下载cocos2d http://www.cocos2d-iphone.org/download 当前stable版本是1.01

第二步: 找一个目录解压缩 cocos2d-iphone-1.0.1.tar.gz
第三步: terminal下切换到解压后的cocos2d-目录 cd cocos2d-iphone-1.0.1 输入”./install-templates.sh -u” 回车,这样cocos2d就安装完了

第四步: 打开xcode 新建一个cocos2d项目,项目名称HelloWorldCo2D

项目建好后,点击左上角的 Run 一个cocos2d的hello world完成了


(看官:“什么?大哥这就完了么?这也太水了吧”)
(doninox:。。。。。。)
好吧,我们现在给helloworld加入自己的一点东西。
第五步: 加入触摸功能,打开项目中的HelloWorldLayer.m,找到init()方法中,我们给label标签加一个数字13,这样以后就可以通过数字来访问标签对象。tag数字要为正正数,每个对象tag不能一样
label.tag = 13;
self.isTouchEnabled = YES;
在次运行Run 现在可以使用鼠标模拟触摸,helloworld的字体大小会随之改变,怎么样触摸(鼠标)后变小了吧

(看官:再加点什么,还是太简单了)
(doninox:。。。。。)
第六步: 增加action,是不是觉得还是很简单呢,我们增加一些动作让这个程序看起来更好点。增加一个精灵做360度旋转同时跳跃从屏幕由左到右,再由右到左,重复3次。
再次回到HelloWorldLayer.m的init()方法,继续添加以下代码。
id action = [CCScaleBy actionWithDuration:3.0f scale:2.5f]; //增加一个动作
[label runAction:action]; //让label运行action
CCSprite *sprite = [CCSprite spriteWithFile:@"Icon.png"]; //建立一个小精灵
sprite.position = ccp(0,50); //位置
[self addChild:sprite z:1]; //增加到场景
id rotateAction = [CCRotateBy actionWithDuration:4 angle:180*4]; //旋转动作
id jumpAction = [CCJumpBy actionWithDuration:4 position:ccp(size.width,0) height:100 jumps:4]; //跳跃动作
id forward = [CCSpawn actions:rotateAction,jumpAction, nil];
id backward = [forward reverse];
id senquence = [CCSequence actions:forward,backward, nil];
id repeat = [CCRepeat actionWithAction:senquence times:10];
[sprite runAction:repeat];
完成后再Run一下
