1.这是AppDelegate里的方法
bool AppDelegate::applicationDidFinishLaunching() {@H_301_3@ // initialize director@H_301_3@ auto director = Director::getInstance();@H_301_3@ auto glview = director->getOpenGLView();@H_301_3@ if(!glview) {@H_301_3@ glview = GLView::create("My Game");@H_301_3@ glview->setFrameSize(800,480);//这里的屏幕大小是指的Windowns下的,对手机没有效果@H_301_3@ director->setOpenGLView(glview);@H_301_3@ }@H_301_3@ @H_301_3@ @H_301_3@ // turn on display FPS@H_301_3@ director->setDisplayStats(false);
//*****************关键点,在这里加上下面俩句话,就实现了手机的屏幕适配
auto designSize = Size(800,480);@H_301_3@ glview->setDesignResolutionSize(designSize.width,designSize.height,ResolutionPolicy::SHOW_ALL);
@H_301_3@ //CCEGLView::sharedOpenGLView()->setDesignResolutionSize(800.0f,480.0f,kResolutionExactFit);@H_301_3@ // set FPS. the default value is 1.0/60 if you don't call this@H_301_3@ director->setAnimationInterval(1.0 / 60);@H_301_3@ @H_301_3@ @H_301_3@ // create a scene. it's an autorelease object@H_301_3@ auto scene = MyTouchEvent2::createScene();@H_301_3@ @H_301_3@ @H_301_3@ // run@H_301_3@ director->runWithScene(scene);@H_301_3@ @H_301_3@ @H_301_3@ return true;@H_301_3@ }@H_301_3@
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { glview = GLView::create("My Game"); glview->setFrameSize(800,480); director->setOpenGLView(glview); } // turn on display FPS director->setDisplayStats(false); auto designSize = Size(800,480); glview->setDesignResolutionSize(designSize.width,ResolutionPolicy::SHOW_ALL); //CCEGLView::sharedOpenGLView()->setDesignResolutionSize(800.0f,kResolutionExactFit); // set FPS. the default value is 1.0/60 if you don't call this director->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object auto scene = MyTouchEvent2::createScene(); // run director->runWithScene(scene); return true; }