《Cocos2D编程.ppt》由会员分享,可在线阅读,更多相关《Cocos2D编程.ppt(9页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Cocos2D编程Iphone开发Snow Leopard 10.6.2Linux+X内核XcodeDarwinVmware 7.0仿真Cocos2D简介基于OpenGL-ES的2D开发框架物理引擎Box2DChipMunk声音引擎CocosDenshion入门-main/main entry point.Like any c or c+program,the main is the entry point/int main(int argc,char*argv)/it is safe to leave these lines as they are.NSAutoreleasePool*poo
2、l=NSAutoreleasePool new;UIApplicationMain(argc,argv,nil,AppController);pool release;return 0;入门-AppControllerinterface AppController:NSObject/main UIWindow/The OpenGL view will be a attached to this UIWindow UIWindow*window;/Make the main UIWindow a propertyproperty(nonatomic,retain)UIWindow*window;
3、end/HelloWorld Layerinterface HelloWorld:CCLayerend入门-applicationDidFinishLaunching(void)applicationDidFinishLaunching:(UIApplication*)application/Try to use CADisplayLink director/if it fails(SDK 3.1)use Threaded directorif(!CCDirector setDirectorType:kCCDirectorTypeDisplayLink)CCDirector setDirect
4、orType:kCCDirectorTypeDefault;/create an initilize the main UIWindowwindow=UIWindow alloc initWithFrame:UIScreen mainScreen bounds;/Attach cocos2d to the windowCCDirector sharedDirector attachInWindow:window;/before creating any layer,set the landscape modeCCDirector sharedDirector setDeviceOrientat
5、ion:kCCDeviceOrientationLandscapeLeft;/Make the window visiblewindow makeKeyAndVisible;/Create and initialize parent and empty SceneCCScene*scene=CCScene node;/Create and initialize our HelloWorld LayerCCLayer*layer=HelloWorld node;/add our HelloWorld Layer as a child of the main scenescene addChild:layer;/Run!CCDirector sharedDirector runWithScene:scene;入门-CCScene,CCLayer,CCSpriteCCScene场景菜单游戏(第一幕,第二幕)结尾CCLayer一个CCScene里有多个Layer每个Layer里有多个CCSprite(精灵)CCSprite行为-Action属性材质-Texture事件-Event有趣的东东行为-CCAction字体-CCBitmapFontAtlas菜单-CCMenu粒子系统-CCParticleSystem动画-CCAnimate例子40多个例子
限制150内