文章出自于  http://blog.csdn.net/zhouyunxuan

RootViewController.h

#import <UIKit/UIKit.h>@interface RootViewController : UIViewController {}
- (BOOL) prefersStatusBarHidden;@end

RootViewController.cpp

#import "RootViewController.h"
#import "cocos2d.h"
#import "CCEAGLView.h"@implementation RootViewController/*// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {// Custom initialization}return self;
}
*//*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*//*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {[super viewDidLoad];
}*/
// Override to allow orientations other than the default portrait orientation.
// This method is deprecated on ios6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {return UIInterfaceOrientationIsLandscape( interfaceOrientation );
}// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0return UIInterfaceOrientationMaskAllButUpsideDown;
#endif
}//是否自己主动旋转
- (BOOL) shouldAutorotate {return YES;
}//这个函数时用来确定我们的应用所支持的旋转方向。假设想要支持每一个方向则直接返回YES即可,还能够单独推断某一方向:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];//设置旋转到某个地方/*UIInterfaceOrientationPortrait: 正常UIInterfaceOrientationPortraitUpsideDown: 转180度UIInterfaceOrientationLandscapeLeft: 向左转90度UIInterfaceOrientationLandscapeRight: 向右转90度*///处理转移到某个角度的时候要做的事情if (fromInterfaceOrientation == UIInterfaceOrientationPortrait) {//}else if (fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){//}else if (fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){//}else if (fromInterfaceOrientation == UIInterfaceOrientationLandscapeRight){//}cocos2d::GLView *glview = cocos2d::Director::getInstance()->getOpenGLView();if (glview){CCEAGLView *eaglview = (CCEAGLView*) glview->getEAGLView();if (eaglview){CGSize s = CGSizeMake([eaglview getWidth], [eaglview getHeight]);cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.width, (int) s.height);}}
}//fix not hide status on ios7
- (BOOL)prefersStatusBarHidden
{return YES;
}- (void)didReceiveMemoryWarning {// Releases the view if it doesn't have a superview.[super didReceiveMemoryWarning];// Release any cached data, images, etc that aren't in use.
}- (void)viewDidUnload {[super viewDidUnload];// Release any retained subviews of the main view.// e.g. self.myOutlet = nil;
}- (void)dealloc {[super dealloc];
}@end

AppController.h

#import <UIKit/UIKit.h>@class RootViewController;@interface AppController : NSObject <UIApplicationDelegate> {UIWindow *window;
}@property(nonatomic, readonly) RootViewController* viewController;@end

AppController.mm

#import "AppController.h"
#import "CCEAGLView.h"
#import "cocos2d.h"
#import "AppDelegate.h"
#import "RootViewController.h"@implementation AppController#pragma mark -
#pragma mark Application lifecycle// cocos2d application instance
static AppDelegate s_sharedApplication;- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    // Override point for customization after application launch.// Add the view controller's view to the window and display.window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];// Init the CCEAGLViewCCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]pixelFormat: kEAGLColorFormatRGBA8depthFormat: GL_DEPTH24_STENCIL8_OESpreserveBackbuffer: NOsharegroup: nilmultiSampling: NOnumberOfSamples: 0];// Use RootViewController manage CCEAGLView _viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];_viewController.wantsFullScreenLayout = YES;_viewController.view = eaglView;// Set RootViewController to windowif ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0){// warning: addSubView doesn't work on iOS6[window addSubview: _viewController.view];}else{// use this method on ios6[window setRootViewController:_viewController];}[window makeKeyAndVisible];[[UIApplication sharedApplication] setStatusBarHidden:true];// IMPORTANT: Setting the GLView should be done after creating the RootViewControllercocos2d::GLView *glview = cocos2d::GLView::createWithEAGLView(eaglView);cocos2d::Director::getInstance()->setOpenGLView(glview);cocos2d::Application::getInstance()->run();return YES;
}- (void)applicationWillResignActive:(UIApplication *)application {/*Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.*///We don't need to call this method any more. It will interupt user defined game pause&resume logic/* cocos2d::Director::getInstance()->pause(); */
}- (void)applicationDidBecomeActive:(UIApplication *)application {/*Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.*///We don't need to call this method any more. It will interupt user defined game pause&resume logic/* cocos2d::Director::getInstance()->resume(); */
}- (void)applicationDidEnterBackground:(UIApplication *)application {/*Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. If your application supports background execution, called instead of applicationWillTerminate: when the user quits.*/cocos2d::Application::getInstance()->applicationDidEnterBackground();
}- (void)applicationWillEnterForeground:(UIApplication *)application {/*Called as part of  transition from the background to the inactive state: here you can undo many of the changes made on entering the background.*/cocos2d::Application::getInstance()->applicationWillEnterForeground();
}- (void)applicationWillTerminate:(UIApplication *)application {/*Called when the application is about to terminate.See also applicationDidEnterBackground:.*/
}#pragma mark -
#pragma mark Memory management- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {/*Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.*/
}- (void)dealloc {[window release];[super dealloc];
}@end
didFinishLaunchingWithOptions
2014-07-28 10:07:41.247 SKT iOS[1024:60b] cocos2d: surface size: 1024x768
cocos2d: GLView End
cocos2d:
{cocos2d.x.version: cocos2d-x 3.1.1 - modify by zyxcocos2d.x.compiled_with_gl_state_cache: truecocos2d.x.build_type: DEBUGgl.supports_vertex_array_object: truecocos2d.x.compiled_with_profiler: falsegl.renderer: Apple Software Renderergl.vendor: Apple Computer, Inc.gl.max_texture_size: 4096gl.max_samples_allowed: 4gl.version: OpenGL ES 2.0 APPLE-9.4.3gl.supports_S3TC: falsegl.supports_ATITC: falsegl.supports_ETC1: falsegl.max_texture_units: 8gl.supports_PVRTC: truegl.supports_NPOT: truegl.supports_discard_framebuffer: truegl.supports_BGRA8888: false
}libpng warning: iCCP: known incorrect sRGB profile
cocos2d: GLProgramState::init
cocos2d: Director End
AppDelegate::applicationDidFinishLaunching()
cocos2d: Application End
applicationDidBecomeActive
Application 单例的实现方法
//静态函数调用的时候会运行一次构造函数,这个时候就初始化这个对象了。
Application* Application::getInstance()
{CC_ASSERT(sm_pSharedApplication);return sm_pSharedApplication;
}
//初始化
Application* Application::sm_pSharedApplication = 0;
//Application的构造函数
Application::Application()
{//在构造函数里面初始化sm_pSharedApplicationCC_ASSERT(! sm_pSharedApplication);sm_pSharedApplication = this;
}
//Application的析构函数
Application::~Application()
{CC_ASSERT(this == sm_pSharedApplication);sm_pSharedApplication = 0;
}
Director 单例实现方法
static DisplayLinkDirector *s_SharedDirector = nullptr;
static Director* getInstance();
Director* Director::getInstance()
{if (!s_SharedDirector){s_SharedDirector = new DisplayLinkDirector();s_SharedDirector->init();}return s_SharedDirector;
}
void Director::setOpenGLView(GLView *openGLView)
{CCASSERT(openGLView, "opengl view should not be null");if (_openGLView != openGLView){// Configuration. Gather GPU infoConfiguration *conf = Configuration::getInstance();conf->gatherGPUInfo();CCLOG("%s\n",conf->getInfo().c_str());if(_openGLView)_openGLView->release();_openGLView = openGLView;_openGLView->retain();// set size_winSizeInPoints = _openGLView->getDesignResolutionSize();createStatsLabel();if (_openGLView){setGLDefaultValues();}//初始化renderer_renderer->initGLView();CHECK_GL_ERROR_DEBUG();if (_eventDispatcher){_eventDispatcher->setEnabled(true);}}
}

cocos2d-x 3.1.1 学习笔记[21]cocos2d-x 创建过程相关推荐

  1. cocos2d-x 3.1.1 学习笔记[15] Shader 著色器

    首先须要两个文件 gray.fsh varying vec4 v_fragmentColor; varying vec2 v_texCoord; void main() {vec4 v_orColor ...

  2. cocos2d-x 3.1.1 学习笔记[17] 关于这些活动功能

    供cocos2d-x通常使用的方法,我有一个好脸色.这项研究真的奖励. 向导首先,定义,实施一系列连续动作. 对于我们的行动能回调函数,我们必须申报并加以实施. void callBack();voi ...

  3. oracle修改asm参数文件,学习笔记:Oracle RAC参数文件管理 修改创建asm中的spfile文件...

    天萃荷净 Oracle rac创建修改asm中的spfile文件内容 create spfile to asm --查看sid SQL> show parameter instance_name ...

  4. 深度学习笔记(21) 边缘检测

    深度学习笔记(21) 边缘检测 1. 边缘检测简介 2. 过滤器 3. 垂直和水平边缘检测 4. 合适的过滤器 1. 边缘检测简介 在计算机视觉中使用的比较多的就是卷积神经网络 卷积运算是卷积神经网络 ...

  5. python数据挖掘学习笔记】十三.WordCloud词云配置过程及词频分析

    #2018-03-28 09:59:40 March Wednesday the 13 week, the 087 day SZ SSMR 11,12因为涉及到数据库被我暂时放弃了 python数据挖 ...

  6. IOS学习笔记05---C语言程序的开发运行过程

    IOS学习笔记05---C语言程序的开发运行过程 0 5.C语言3-C语言程序的开发运行过程 ----------------------------------------------------- ...

  7. Windows Workflow HOL学习笔记(十二):创建状态基工作流

    W indows Workflow HOL学习笔记(十二):创建状态基工作流 本文内容来自Microsoft Hands-on Labs for Windows Workflow Foundation ...

  8. 几何光学学习笔记(21)- 5.4 渐晕光阑

    几何光学学习笔记(21)- 5.4 渐晕光阑 5.4 渐晕光阑. 1.轴外点发出光束的渐晕 2.消除渐晕的条件 3.渐晕系数 3.1线渐晕系数 3.2几何渐晕系数 5.4 渐晕光阑. 1.轴外点发出光 ...

  9. Vue学习笔记(2) 在html文件中创建Vue实例,并使用http-vue-loader注册单文件组件

    本篇博客基于Vue2.x 官方文档:https://cn.vuejs.org/v2/guide/instance.html 最近和同学合作一个设备信息管理的小项目,而同学找的模板不是前后端分离的 因此 ...

  10. 影像组学视频学习笔记(42)-影像组学特征提取问题解决过程复现、Li‘s have a solution and plan.

    作者:北欧森林 链接:https://www.jianshu.com/p/c3e6de2f79b3 来源:简书,已获转载授权 本笔记来源于B站Up主: 有Li 的影像组学系列教学视频 本节(42)主要 ...

最新文章

  1. perl脚本发送邮件
  2. nyist 303 序号互换
  3. arp的***和防御
  4. python项目策划书_跟着销售学python系列(1)--实践项目骨架(1)
  5. java 多表格处理工具,表单工具十一大标准
  6. React开发(103):详细路径 不然找不到
  7. android多个水波球,android球形水波百分比控件代码
  8. [转载] 推荐的C++书籍以及阅读顺序
  9. 2020中软java面试题,通过这9个Java面试题,就可以入职华为啦
  10. 【关系抽取】详聊如何用BERT实现关系抽取
  11. windows 搭建简单c++环境【mingw】
  12. sklearn 中的 Iris 数据集
  13. 【CodingNoBorder - 10】无际软工队 - 求职岛:ALPHA 阶段事后分析
  14. VMware Workstation 不可恢复错误: (vcpu-0)解决方法
  15. android面试之怎么把图片变成圆形
  16. 从美术生到程序员转型之路【我的故事】
  17. java中高级面试_中高级面试常问:Java面向对象设计的六大原则
  18. margin-left:-100%
  19. 不联网也传染!新型病毒通过USB无线传输传播
  20. 图解希尔排序(Shell Sort)

热门文章

  1. 使用squid代理后某些网站无法访问的解决办法(3.1.7版本)
  2. 用 SQL 脚本读取Excel 中的sheet数量及名称
  3. mysql查询结果进行排名
  4. 集合之HashSet
  5. Weblogic常见故障常:JDBC Connection Pools
  6. 多线程设计模式总结(一)
  7. java中substring与substr的用法
  8. HTML5实践 -- 可伸缩的mobile搜索框
  9. 个利用正则表达式解析单句SQL的类SqlParser
  10. 利用分类模型学习特征权重