AppDelegate.h
2019独角兽企业重金招聘Python工程师标准>>>
#ifndef __APP_DELEGATE_H__
#define __APP_DELEGATE_H__#include "CCApplication.h"
//CCApplication.h能根据平台打开对应的平台头文件
/**
@brief The cocos2d Application.The reason for implement as private inheritance is to hide some interface call by CCDirector.
*/
class AppDelegate : private cocos2d::CCApplication
{
public:AppDelegate();virtual ~AppDelegate();/**@brief Implement for initialize OpenGL instance, set source path, etc...*/virtual bool initInstance();/**@brief Implement CCDirector and CCScene init code here.@return true Initialize success, app continue.@return false Initialize failed, app terminate.*/virtual bool applicationDidFinishLaunching();/**@brief The function be called when the application enter background@param the pointer of the application*/virtual void applicationDidEnterBackground();/**@brief The function be called when the application enter foreground@param the pointer of the application*/virtual void applicationWillEnterForeground();
};#endif // __APP_DELEGATE_H__
#include "AppDelegate.h"
#include "cocos2d.h"
#include "HelloWorldScene.h"
#include "CCEGLView.h"USING_NS_CC;AppDelegate::AppDelegate()
{
}AppDelegate::~AppDelegate()
{
}bool AppDelegate::initInstance()
{bool bRet = false;do{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)// Initialize OpenGLView instance, that release by CCDirector when application terminate.// The HelloWorld is designed as HVGA.CCEGLView * pMainWnd = new CCEGLView();CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));#endif // CC_PLATFORM_WIN32#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.#endif // CC_PLATFORM_IOS#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)// OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp// the default setting is to create a fullscreen view// if you want to use auto-scale, please enable view->create(320,480) in main.cpp// if the resources under '/sdcard" or other writeable path, set it.// warning: the audio source should in assets/// cocos2d::CCFileUtils::setResourcePath("/sdcard");#endif // CC_PLATFORM_ANDROID#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)// Initialize OpenGLView instance, that release by CCDirector when application terminate.// The HelloWorld is designed as HVGA.CCEGLView* pMainWnd = new CCEGLView(this);CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480, WM_WINDOW_ROTATE_MODE_CW));#ifndef _TRANZDA_VM_// on wophone emulator, we copy resources files to Work7/NEWPLUS/TDA_DATA/Data/ folder instead of zip filecocos2d::CCFileUtils::setResource("HelloWorld.zip");
#endif#endif // CC_PLATFORM_WOPHONE
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)// MaxAksenov said it's NOT a very elegant solution. I agree, hahaCCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)// Initialize OpenGLView instance, that release by CCDirector when application terminate.// The HelloWorld is designed as HVGA.CCEGLView * pMainWnd = new CCEGLView();CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create("cocos2d: Hello World", 800, 480,480, 320));CCFileUtils::setResourcePath("../Resource/");#endif // CC_PLATFORM_LINUX#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)CCEGLView * pMainWnd = new CCEGLView();CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this, 480, 320));pMainWnd->setDeviceOrientation(Osp::Ui::ORIENTATION_LANDSCAPE);CCFileUtils::setResourcePath("/Res/");#endif // CC_PLATFORM_BADA#if (CC_TARGET_PLATFORM == CC_PLATFORM_QNX)CCEGLView * pMainWnd = new CCEGLView();CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(480, 320));CCFileUtils::setResourcePath("./app/native/Resource");
#endif // CC_PLATFORM_QNXbRet = true;} while (0);return bRet;
}bool AppDelegate::applicationDidFinishLaunching()
{// initialize directorCCDirector *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 FPSpDirector->setDisplayFPS(true);// set FPS. the default value is 1.0/60 if you don't call thispDirector->setAnimationInterval(1.0 / 60);// create a scene. it's an autorelease objectCCScene *pScene = HelloWorld::scene();// runpDirector->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()->pause();
}// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{CCDirector::sharedDirector()->resume();
}
1
转载于:https://my.oschina.net/ajian2014/blog/282621
AppDelegate.h相关推荐
- 项目中AppDelegate详解
1.AppDelegate.h //模板默认引入程序需要使用"类"的框架,即UIKit.h头文件,使它包含在程序中 #import <UIKit/UIKit.h> // ...
- 2 自己编写:AppDelegate,CCApplication,CCApplicationProtocol
1 CCApplicationProtocol.h /* * CCApplicationProtocol.h * * Created on: 2014年10月19日 * Author: t ...
- AppDelegate
一.基础知识 1) main.m指定了程序的入口点 UIApplicationMain(argc, argv,nil,NSStringFromClass([StartingPointAppDelega ...
- IOS AppDelegate详解
AppDelegate.h模板 //模板默认引入程序需要使用"类"的框架,即UIKit.h头文件,使它包含在程序中 #import //此处@class声明程序中的"类& ...
- iOS 删除 SceneDelegeta.h
下面展示一些 内联代码片. # 删除项目 SceneDelegeta 文件 // 删除SceneDelegeta.h和SceneDelegeta.m这两个文件 // 在AppDelegate.h里面添 ...
- ios逆向工具Class-dump的安装和导出.h文件的教程
目录 官网文件安装方法 运行报错 Cannot find offset for address xxx in stringAtAddress: 解决运行报错的版本下载地址: 获取app文件 class ...
- nsobjcruntime.h 报错
-----错误产生: 最近在给2dx-lua quick3.3项目接iOS广告SDK时,修改了Build Settings->Linking中的Other Linker Flags为-ObjC ...
- [AppDelegate window]: unrecognized selector sent to instance 0x600002b178e0
[AppDelegate window]: unrecognized selector sent to instance 0x600002b178e0 SVProgressHUD https://gi ...
- iOS开发8:使用Tool Bar切换视图
之前讨论的都是单视图应用程序,而在实际应用中,我们可能要多个视图,并根据用户的需要切换视图. iOS中几种典型的多视图程序: (1)Tab Bar Application:程序的底部有一排按钮,轻触其 ...
最新文章
- 你必须非常努力,才能看起来毫不费力
- ORACLE 12C安装
- api接口rsa加密
- 容器技术之二.Docker的安装和常见问题
- 1月份Web服务器份额:Microsoft涨2.32%居亚
- Codeforces Round #735 (Div. 2)
- P3388-[模板]割点(割顶)【tarjan】
- 第五十一期:AIOps落地关键点指南
- oracle只匹配中文,Oracle 实现 一个关键字 匹配多个 字段
- linux卸载nomachine,NoMachine 安装与配置及使用
- 喜用神最正确的算法_各种电磁仿真算法的优缺点和适用范围(FDTD, FEM和MOM等)...
- 一种多功能语音识别技术和音乐播放器相结合的方法
- 微服务学习之Hystrix容错保护【Hoxton.SR1版】
- 计算机基础知识_进制转化
- 数据仓库建设 —— 数据质量管理
- win7下如何快速打开便笺或便签实用小工具
- android停止补间动画,android 帧动画,补间动画,属性动画的简单总结
- 【Java框架】CSFramework框架的应用——简易聊天室
- 大学英语精读第三版(第五册)复习笔记——文章内容摘要
- python计算单词长度_python – 返回字符串中的单词长度
热门文章
- python函数星号参数
- Github(2)-本地配置git
- 深度学习(08)-- Residual Network (ResNet)
- 剑指offer(刷题41-50)--c++,Python版本
- 《Python Cookbook 3rd》笔记(5.6):字符串的 I/O 操作
- 《Python Cookbook 3rd》笔记(3.14):计算当前月份的日期范围
- python3.5.2安装pygame_【闲来无事,py写game】Mac-Python3.5安装pygame 1.9.2 小计
- STL源码剖析 Stack栈 queue队列
- 使用C++的方式实现AES算法
- Python学习6 字典基础知识和常用函数