cocos2dx之AppDelegate
2014-01-13 23:28
155 查看
在创建完了工程之后,我们可以看到AppDelegate这个文件,我们打开看下这里面有什么:
从上面分析:
AppDelegate其实就是整个程序的入口,它的初始化步骤就是上面的1-3,4则是在手机后台运行该程序时所调用的
AppDelegate::AppDelegate() { //1,构造AppDelegate } AppDelegate::~AppDelegate() { } bool AppDelegate::applicationDidFinishLaunching() {//3,在2初始化完之后进入,结束初始化appDelegate // initialize director CCDirector* pDirector = CCDirector::sharedDirector(); CCEGLView* pEGLView = CCEGLView::sharedOpenGLView(); pDirector->setOpenGLView(pEGLView); // 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); CCScene * pScene = CCScene::create(); GameDemoManager * pLayer = new GameDemoManager(); pLayer->initGame(); pLayer->autorelease(); pScene->addChild(pLayer); pDirector->runWithScene(pScene); return true; } // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() {//4,当手机处于后台运行的时候,进入该处 CCDirector::sharedDirector()->stopAnimation(); // if you use SimpleAudioEngine, it must be pause // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); } // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { /,2,构造完了AppDelegate之后进入初始化application CCDirector::sharedDirector()->startAnimation(); // if you use SimpleAudioEngine, it must resume here // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); }
从上面分析:
AppDelegate其实就是整个程序的入口,它的初始化步骤就是上面的1-3,4则是在手机后台运行该程序时所调用的
相关文章推荐
- iOS培训——Cocos2dx基础篇AppDelegate
- 一个cocos2dx 游戏解读(AppDelegate)
- Cocos2dx中AppDelegate生命周期
- cocos2dx 入口类AppDelegate.cpp及屏幕适配
- cocos2dx 3.7中 AppDelegate.h的class TestController;这种写法的具体意思不太明白,只能猜是类似于外部定义的东西。
- 从Delphi开始学Cocos2dx-3.0[1]: AppDelegate 与 Application
- cocos2dx 打开邮件App以及URL
- iOS AppDelegate的详解
- AppDelegate的详解
- iOS开发-appDelegate的生命周期总结
- 从头开始读cocos2d-x-3.2alpha0 (1) 了解AppDelegate
- cocos2dx ios app名称添加国际化
- Cocos2Dv3.4在AppDelegate中不返回的情况及解决
- appDelegate
- ios appdelegate中获取当前显示页
- 在appdelegate内设置导航控制器为根控制器
- cocos2dx xcoder 上传APP审核碰到的各种问题整理
- IOS的AppDelegate方法中的事件触发调用
- 如何在ViewController里调用appdelegate里的方法
- iOS推送AppDelegate跳转任意VC