2.4 AppDelegate 的 3 个生命周期
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函数。
*/
2.4 AppDelegate 的 3 个生命周期的更多相关文章
- iOS程序执行顺序 AppDelegate及 UIViewController 的生命周期
iOS程序的启动执行顺序 AppDelegate 及 UIViewController 的生命周期 iOS应用程序的状态切换很重要,而UIViewControler对于iOS这种MVC模式来说尤为重要 ...
- [iOS]应用与视图的生命周期和方法调用
1.应用程序的生命周期: AppDelegate类在应用生命周期的不同阶 会回调不同的方法. 视图push到了子界面,然后子界面pop回原界面的时候,会启用viewWillAppear以及之后的几个生 ...
- iOS应用生命周期
作为应用程序的委托对象,AppDelegate类在应用生命周期的不同阶段会回调不同的方法.首先,让我们先了解一下iOS 应用的不同状态及它们彼此间的关系,见图1 . 图1 iOS应用状态图 下面简要介 ...
- iOS程序执行顺序和UIViewController 的生命周期(整理)
说明:此文是自己的总结笔记,主要参考: iOS程序的启动执行顺序 AppDelegate 及 UIViewController 的生命周期 UIView的生命周期 言叶之庭.jpeg 一. iOS程序 ...
- 12、Cocos2dx 3.0游戏开发找小三之3.0中的生命周期分析
重开发人员的劳动成果.转载的时候请务必注明出处:http://blog.csdn.net/haomengzhu/article/details/27706303 生命周期分析 在前面文章中我们执行了第 ...
- IOS应用程序生命周期的AppDelegate详解
IOS 中的 AppDelegate.m/h 文件是很重要的呢,因为它是对 Application 的整个生命周期进行管理的. 先明白,每个iPhone应用程序都有一个UIApplication,UI ...
- Info.plist和pch文件的作用,UIApplication,iOS程序的启动过程,AppDelegate 方法解释,UIWindow,生命周期方法
Info.plist常见的设置 建立一个工程后,会在Supporting files文件夹下看到一个“工程名-Info.plist”的文件,该文件对工程做一些运行期的配置,非常重要,不能删除 注:在旧 ...
- [转] IOS中AppDelegate中的生命周期事件的调用条件
IOS中AppDelegate中的生命周期事件的调用条件 //当应用程序将要进入非活动状态执行,在此期间,应用程序不接受消息或事件,比如来电 - (void)applicationWillResign ...
- AIR Native Extension for iOS 接入第三方sdk 如何实现 AppDelegate 生命周期
作者:Panda Fang 出处:http://www.cnblogs.com/lonkiss/p/6492385.html 原创文章,转载请注明作者和出处,未经允许不可用于商业营利活动 去年到今年做 ...
随机推荐
- jQuery动态加载JS以减少服务器压力
如果您要创建一个web2.0的应用程序,那么你的网页会包括大量的JavaScript文件,这些可能会拖慢您的网页.因此,动态加载JavaScript代码到您的网页是一个好主意,即只有当实用他们的时候加 ...
- WebView 显示网页
1.布局 <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:androi ...
- web安全之SQL注入--第一章 课程介绍
课程介绍1.什么是SQL注入?2.如何寻找SQL注入漏洞?3.如何进行sql注入攻击?4.如何预防sql注入5.课程总结
- Excel中批量把数字类型转换为文本类型
客户给的excel文件中的内容全部是数值类型,这些我们要当成文本存入到数据库,所以需要把所有的数值转换为文本,但是直接通过修改单元格属性来修改的话会变成科学技数法,还有一种方法是在数值得前面加个英文的 ...
- 石子合并DP
DP Time Limit:3000MS Memory Limit:131072KB 64bit IO Format:%lld & %llu Submit Status Pra ...
- springboot + swagger2 学习笔记
引入步骤 1.添加依赖 <dependency> <groupId>io.springfox</groupId> <artifactId>springf ...
- 被学长教会的高斯消元法Gauss
昨天学长教了我高斯消元法. 这里用一个栗子来模拟一下Gauss的流程. 真的通俗易懂!这里是洛谷题目链接. 这就是例子 x-2y+3z= 4x-5y+6z= 7x-8y+10z= 先将它转化为矩阵 - ...
- Java 迭代器
1.快速报错 public class FailFast { public static void main(String[] args) { List<String> c = new A ...
- centos7.0下删除yum和python之后恢复的办法
centos 7如果卸载了yum和python之后恢复的办法(该方法已经测试). 下载 地址 http://mirrors.163.com/centos/7/os/x86_64/Packages/ 下 ...
- 爬虫-【selenium—Webdriver元素定位的八种常用方式
在使用selenium webdriver进行元素定位时,通常使用findElement或findElements方法结合By类返回的元素句柄来定位元素.其中By类的常用定位方式共八种,现分别介绍如下 ...