COCOS2D-X 的启动流程

首先,在main.cpp中会先执行
 AppDelegate app;
   CCEGLView* eglView = CCEGLView::sharedOpenGLView();
   //设置窗口名
   eglView->setViewName("Hoooooo");
   //设置窗口大小
   eglView->setFrameSize(480, 320);
   int ret = CCApplication::sharedApplication()->run();


随后运行
bool AppDelegate::applicationDidFinishLaunching()
{
   //初始化设置导演
   CCDirector *pDirector = CCDirector::sharedDirector();
   pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());


   //开启FPS模式
   pDirector->setDisplayStats(true);


   //设置FPS. 默认是60帧
   pDirector->setAnimationInterval(1.0 / 60);


   //创建一个场景 把HelloWorld的场景指针指向来
   /
   //    在类HelloWorldScene.h中 HelloWorld 写了 static cocos2d::CCScene* scene();用于来   得到场景指针。
   //
   //    HelloWorld本身继承了cocos2d::CCLayer 在 HelloWorldScene.cpp的   HelloWorld::scene()的实现中,HelloWorld本身就添加到场景中通过: 
   //    HelloWorld *layer = HelloWorld::create();
   //    scene->addChild(layer);
   //
   //    其中layer是一个自动释放的对象,原因在于HelloWorld::create();就在是   CREATE_FUNC(HelloWorld);中定义的.
   //    宏CREATE_FUNC(__TYPE__)会设置其自动释放内存,方便内存管理,不需要手动去释放
   //
   /
   CCScene *pScene = HelloWorld::scene();
 
   //导演运行这个场景
   pDirector->runWithScene(pScene);
   return true;
}

下来的添加操作就是在HelloWorld的这个layer图层中进行的了。


在各个平台上面都是这样,比如android,是通过在一个activity(继承自cocos2dactivity),中开始进入c接口,然后开始通过代理加载。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值