Last active
December 15, 2015 04:29
-
-
Save tadamatu/5201880 to your computer and use it in GitHub Desktop.
cocos2dxの解像度対応
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//画面解像度対応 | |
// 480x320ベースで実装を行う(iPhone 4inchのみ568x320) | |
// 画像は以下のそれぞれのフォルダより取得 | |
// @2x Resources/Published-iOS/resources-iphonehd | |
// 通常 Resources/Published-iOS/resources-iphone | |
//※AppDelegate::applicationDidFinishLaunching{} に実装する | |
// this->changeDisplayHd(); | |
void AppDelegate::changeDisplayHd() { | |
CCDirector *pDirector = CCDirector::sharedDirector(); | |
CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize(); | |
std::vector<std::string> searchPaths; | |
std::vector<std::string> resDirOrders; | |
TargetPlatform platform = CCApplication::sharedApplication()->getTargetPlatform(); | |
if (platform == kTargetIphone || platform == kTargetIpad){ | |
searchPaths.push_back("Published-iOS"); // Resources/Published-iOS | |
if (screenSize.height > 480){ | |
//Retainaによる幅調整 | |
resDirOrders.push_back("resources-iphonehd"); //Resources/Published-iOS/resources-iphonehd | |
pDirector->setContentScaleFactor(2.f); //2倍のスケールサイズ | |
if (screenSize.width==1136.0 || screenSize.height==1136.0 ) { | |
//4-inch | |
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(568, 320, kResolutionShowAll); | |
} else { | |
//3.5-inch | |
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionShowAll); | |
} | |
}else{ | |
//通常サイズ | |
resDirOrders.push_back("resources-iphone"); //Resources/Published-iOS/resources-iphone | |
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionShowAll); | |
} | |
}else{ | |
// iOS以外(Androidなど) | |
searchPaths.push_back("Published-iOS"); // Resources/Published-iOS | |
resDirOrders.push_back("resources-iphone"); | |
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionExactFit); | |
} | |
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths); | |
CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(resDirOrders); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://tadamatu.blogspot.jp/2013/03/cocos2dx.html