新建项目HelloWorld
文件夹iOS下
AppController.mm //.mm是表示可以用Oc和C++来写
{
//创建一个C++版本的AppDelegate对象 会自动调用构造函数
static AppDelegate s_sharedApplication;
//EAGLView : UIView 是专门用来显示游戏的
/*
EAGLView使用的CAEALLayer做为view核心画图(会使用OpenGL es画图)
UIView使用CALayer做为view的UI画图,界面刷新不高
*/
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
//让状态栏隐藏
[[UIApplication sharedApplication] setStatusBarHidden: YES];
//返回的其实就是s_shareApplition的指针
//run就会调用AppDelegate.cpp里面的appDidFinishedLaunched函数
cocos2d::CCApplication::sharedApplication()->run();
}
RootViewController.mm
{
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//屏幕转屏函数
//如果是横屏才能转
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
}
}
文件Classes---AppDelegate.cpp
{
//AppController.mm中的sharedApplication()->run()函数回调的地方
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
//需要一个导演CCDirector 导演一个单例
CCDirector *pDirector = CCDirector::sharedDirector();
//CCEGLView::sharedOpenGLView()就是取得之前AppController里面创建的ECALView
//setOpenGLView就是告诉pDirector人游戏的view在哪里
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
//启动HelloWorld场景
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
}
文件夹iOS下
AppController.mm //.mm是表示可以用Oc和C++来写
{
//创建一个C++版本的AppDelegate对象 会自动调用构造函数
static AppDelegate s_sharedApplication;
//EAGLView : UIView 是专门用来显示游戏的
/*
EAGLView使用的CAEALLayer做为view核心画图(会使用OpenGL es画图)
UIView使用CALayer做为view的UI画图,界面刷新不高
*/
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
//让状态栏隐藏
[[UIApplication sharedApplication] setStatusBarHidden: YES];
//返回的其实就是s_shareApplition的指针
//run就会调用AppDelegate.cpp里面的appDidFinishedLaunched函数
cocos2d::CCApplication::sharedApplication()->run();
}
RootViewController.mm
{
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//屏幕转屏函数
//如果是横屏才能转
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
}
}
文件Classes---AppDelegate.cpp
{
//AppController.mm中的sharedApplication()->run()函数回调的地方
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
//需要一个导演CCDirector 导演一个单例
CCDirector *pDirector = CCDirector::sharedDirector();
//CCEGLView::sharedOpenGLView()就是取得之前AppController里面创建的ECALView
//setOpenGLView就是告诉pDirector人游戏的view在哪里
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
//启动HelloWorld场景
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
}