show code js

2012年4月27日 星期五

cocos2d

we can use cocos2d development game on iOS


  1. install xcode
  2. goto http://www.cocos2d-iphone.org/
  3. click download tag, and download stable version
  4. create a directory on mac, set it call cocos2d
  5. uncompress and move to cocos2d directory
  6. open terminal and goto cocos2d-iphone-VER directory
  7. use "sudo ./install-templates.sh" to install
  8. when pup a window that you keyin password to contiune to finish.
  9. open xcode and click cocos2d project, and you can see three project templates
  10. choose a template to create new project and building after see a hellow world on screen
  11. if happen warning like this "uniqueIdentifier is deprecated", you can find out those line and command out. because iOS can`t create UDID, but apple have a method to create it.
add a png
  1. copy a png file to project, ex:test.png
  2. edit filename"layer".m
  3. add code and run, you can see test.png on screen and moving.
    // start
    
    // add a png at screen
    CCSprite *spacePng = [CCSprite spriteWithFile:@"test.png"];
    [spacePng setPosition:ccp(100, 100)];
    [self addChild:spacePng];
    
    // let this png moving
    id moveAction = [CCMoveTo actionWithDuration:5.0f position:ccp(300, 200)];
    [spacePng runAction:moveAction];
    
    // end

沒有留言:

張貼留言