转cocos2d 2.0.4 适配分辨率最新写法(最全)

bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();

pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
CCSize designSize = CCSizeMake(480, 320);

//获取屏幕大小
CCSize screenSize =CCDirector::sharedDirector()->getWinSize();

if (screenSize.height == 320)
{
//设置iphone3gs资源路径
CCFileUtils::sharedFileUtils()->setResourceDirectory("sd");


}
else if(screenSize.height==640)
{
//设置iphone4资源路径
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");

}
else if(screenSize.height==768)
{
//设置ipad2和ipadmini资源路径
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");

}
else if(screenSize.height==1536)
{
//设置ipad3资源路径
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");

}
else if(screenSize.width==568)
{
//设置iphone5资源路径
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");

}

CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);

// turn on display FPS
pDirector->setDisplayStats(true);

// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);

// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}

你可能感兴趣的:(cocos2d)