2.4 AppDelegate 的 3 个生命周期
2024-08-24 01:33:42
Classed/AppDelegate.cpp 文件内容如下:
#include "cocos2d.h"
#include "CCEGLView.h"
#include "AppDelegate.h"
#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h" using namespace CocosDenshion; USING_NS_CC; AppDelegate::AppDelegate()
{
} AppDelegate::~AppDelegate()
{
SimpleAudioEngine::end();
} bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director(导演初始化)
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); // turn on display FPS(设置显示状态信息:当前对象个数 每一帧使用时间 当前游戏整体运行帧数)
pDirector->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this(设置游戏帧率为每秒60帧)
pDirector->setAnimationInterval(1.0 / ); // create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene(); // run (运行 HelloWorld 场景)
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()
{
//对整个游戏设置暂停
CCDirector::sharedDirector()->stopAnimation();
//设置暂停音乐
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
} // this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
//设置游戏继续
CCDirector::sharedDirector()->startAnimation();
//设置音乐继续播放
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
} /*
此类含义是当整个项目启动后,Cocos2d-x引擎会从各个平台的入口函数中接管,然后调用
AppDelegate类中的 applicationDidFinishLaunching 函数。
当程序用户切入运行后台的时候,会响应 AppDelegate 类中的 applicationDidEnterBackground 函数。
当程序用户从设备运行后台切回到当前运行程序时,会响应 AppDelegate 类中的 applicationWillEnterForeground函数。
*/
最新文章
- QuanbenSoft Windows Runtime (Windows Store)Apps 应用及其框架总览
- java运算优先级
- JS-Math对象
- 解决(空密码的root)提示修改phpmyadmin用户密码
- hive中导入json格式的数据(hive分区表)
- 未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序的处理方式
- JavaScript Comparison and Logical Operators
- DBMS_RLS包实现数据库表中的行级安全控制
- angularjs自定义日期过滤器,如:周日(前天 21:24)
- Mahout之(二)协同过滤推荐
- 老司机的奇怪noip模拟T3-zhugeliang
- express session 和 socketio session关联
- 2)实现github自动登陆获取信息
- linux内核期中总结
- Android Studio 版本间区别
- spark work目录处理 And HDFS空间都去哪了?
- loading加载和layer.js
- CSS加DIV布局
- 关于 Vue 方法前面的美元符号
- python中hashlib md5
热门文章
- getMeasuredHeight(),getScrollY(),getHeight()的区别和联系
- 使用java命令运行class文件带包名时出错
- Laravel开发:Laravel核心——Ioc服务容器源码解析(服务器绑定)
- js网页视频播放: vcastr22 、 flowplayer 、 jwplayer
- 页游手游服务器(五)sql缓存层
- Codeforces441C_Valera and Tubes(暴力)
- Python 中奇妙的下划线
- (转)Javascript模块化编程(一):模块的写法
- QT设置QToolBar带有图标和文字
- 机器学习Coursera学习总结