您的位置:首页 > 移动开发 > Cocos引擎

cocos2d-x学习之一:cocos2d-x程序的生命周期

2012-10-26 16:11 169 查看
1.main.m(ios为例)程序入口:cocos2d::CCApplication::sharedApplication().run();

2.程序启动之后会调用AppDelegate.cpp中的回调applicationDidFinishLaunching:

bool AppDelegate::applicationDidFinishLaunching()

{

// initialize director

CCDirector *pDirector = CCDirector::sharedDirector();

pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());

// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.

pDirector->enableRetinaDisplay(true);

// turn on display FPS

// pDirector->setDisplayStats(true);

// set FPS. the default value is 1.0/60 if you don't call this

pDirector->setAnimationInterval(1.0 / 60);

// create a scene. it's an autorelease object

CCScene *pScene = MainScene::scene();

// run

pDirector->runWithScene(pScene);

return true;

}

3.通过调用

// create a scene. it's an autorelease object

CCScene *pScene = MainScene::scene();

// run

pDirector->runWithScene(pScene);

来实现加载主界面。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: