cocos2d-x屏幕适配

   
    bool AppDelegate::applicationDidFinishLaunching() {

		CCDirector* pDirector = CCDirector::sharedDirector();
		CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
		pDirector->setOpenGLView(pEGLView);
		pDirector->setDisplayStats(true);
		pDirector->setAnimationInterval(1.0 / 60);
		CCSize frameSize = pEGLView->getFrameSize();
		CCSize winSize=pDirector->getWinSize();
		float widthRate = frameSize.width/winSize.width;
		float heightRate = frameSize.height/winSize.height;
		if (widthRate > heightRate){
			pEGLView->setDesignResolutionSize(winSize.width,
			winSize.height*heightRate/widthRate, kResolutionNoBorder);
		}
		else{
			pEGLView->setDesignResolutionSize(winSize.width*widthRate/heightRate, winSize.height,kResolutionNoBorder);
		}
	
		CCScene *pScene = HelloWorld::scene();
		pDirector->runWithScene(pScene);
		
		return true;
}


你可能感兴趣的:(cocos2d-x屏幕适配问题,cocos2d-x屏幕适配)