加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocos2d学习(03)——AppDelegate类中applicationDidFinishLaunch

发布时间:2020-12-14 19:28:45 所属栏目:百科 来源:网络整理
导读:AppDelegate类中applicationDidFinishLaunching函数分析 1: bool AppDelegate::applicationDidFinishLaunching() { 2: // initialize director 初始化导演 3: CCDirector* pDirector = CCDirector::sharedDirector(); 4: //导演Director也是单例模式的,只能

AppDelegate类中applicationDidFinishLaunching函数分析

 1: bool AppDelegate::applicationDidFinishLaunching() {
 2:     // initialize director 初始化导演
 3:     CCDirector* pDirector = CCDirector::sharedDirector();
 4:     //导演Director也是单例模式的,只能有一个导演
 5:     /* CCDirector* CCDirector::sharedDirector(void)
 6:  {
 7:  if (!s_SharedDirector) //导演不存在的时候
 8:  { //创建一个导演
 9:  s_SharedDirector = new CCDisplayLinkDirector();
 10:  s_SharedDirector->init();
 11:  }
 12: 
 13:  return s_SharedDirector; //返回导演
 14:  }
 15:  //单例模式的一个重要的实现方法,私有化构造函数和静态类指针
 16:  static CCDisplayLinkDirector *s_SharedDirector = NULL;
 17:  *****************************************************/
 18:     CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
 19:
 20:     pDirector->setOpenGLView(pEGLView);
 21:
 22:     // turn on display FPS turn on对准;对…进行突击
 23:     //display显示 (=feet per second)英尺/秒n.【摄】张 / 秒
 24:     pDirector->setDisplayStats(true);
 25:
 26:     // set FPS. the default value is 1.0/60 if you don't call this
 27:     //设置FPS的默认值为60张每秒。
 28:     pDirector->setAnimationInterval(1.0 / 60);
 29:
 30:     // create a scene. it's an autorelease object
 31:     //创建一个场景scene,他会自动释放对象(对象管理池)
 32:     CCScene *pScene = HelloWorld::scene();   //要做的事情都在这里,多数内容都加在这里面
 33: // CCAction* CCAction::create()
 34: // {
 35: // CCAction * pRet = new CCAction();
 36: // pRet->autorelease(); //对象调用创建的时候
 37: // return pRet;
 38: // }
 39: //
 40: // CCObject* CCObject::autorelease(void)
 41: // { //将创建的对象加入到对象管理池
 42: // CCPoolManager::sharedPoolManager()->addObject(this);
 43: // return this;
 44: // }
 45: // //对象管理池也是单实例的
 46: // CCPoolManager* CCPoolManager::sharedPoolManager()
 47: // {
 48: // if (s_pPoolManager == NULL)
 49: // {
 50: // s_pPoolManager = new CCPoolManager();
 51: // }
 52: // return s_pPoolManager;
 53: // }
 54: //
 55: // void CCPoolManager::addObject(CCObject* pObject)
 56: // {
 57: // getCurReleasePool()->addObject(pObject);
 58: // }
 59:
 60:     // run 运行。由导演来使用这个场景
 61:     pDirector->runWithScene(pScene);
 62:     //返回成功
 63:     return true;
 64: }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读