按我的知識,使cocos2dx一個應用程序,我需要三套資源的ipad的,ipadhd和iphone資產尺寸cocos2dx應用
從應用的一個例子,我看到了,爲了支持所有分辨率的設備,資產規模(背景圖像),我的朋友已經使用了:
ipadhd:2272 X 1536
的ipad:1136 X 768
iphone:568 x 384
這些尺寸適用於橫向模式遊戲。 以下是我的問題: 1.爲什麼我們需要這些尺寸? 2.我正在嘗試製作一款肖像模式遊戲,因爲我採用了相同的資產尺寸(但由於我在肖像模式下工作,我將圖像尺寸設置爲1536 X 2272,768 X 1136和384 X 568)。但是,由於某些原因,BG圖像在模擬器/設備上顯示時會被放大。我在這裏附上屏幕截圖。
原始圖像:
圖像顯示在模擬器起來:
作爲參考,這裏是設置設備分辨率大小和內容的比例因子的代碼:
#define TARGET_DESIGN_RESOLUTION_SIZE DESIGN_RESOLUTION_480X320
typedef struct tagResource
{
cocos2d::CCSize size;
char directory[100];
}Resource;
static Resource smallResource = { cocos2d::CCSizeMake(320, 480), "iphone" };
static Resource mediumResource = { cocos2d::CCSizeMake(768,1024), "iPad" };
static Resource largeResource = { cocos2d::CCSizeMake(1536,2048), "ipadhd" };
#if (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_480X320)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(320, 480);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_1024X768)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(768,1024);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_2048X1536)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(1536,2048);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_NONE)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(320, 480);
#else
#error unknown target design resolution!
#endif
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// Set the design resolution
pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height,kResolutionNoBorder);
CCSize frameSize = pEGLView->getFrameSize();
std::vector<std::string> resDirOrders;
// if the frame's height is larger than the height of medium resource size, select large resource.
if (frameSize.width > mediumResource.size.width)
{
resDirOrders.push_back(largeResource.directory);
pDirector->setContentScaleFactor(largeResource.size.width/designResolutionSize.width);
}
// if the frame's height is larger than the height of small resource size, select medium resource.
else if (frameSize.width > smallResource.size.width)
{
resDirOrders.push_back(mediumResource.directory);
pDirector->setContentScaleFactor(mediumResource.size.width/designResolutionSize.width);
}
// if the frame's height is smaller than the height of medium resource size, select small resource.
else
{
resDirOrders.push_back(smallResource.directory);
pDirector->setContentScaleFactor(smallResource.size.width/designResolutionSize.width);
}
CCFileUtils::sharedFileUtils()->setSearchPaths(resDirOrders);
// turn on display FPS
pDirector->setDisplayStats(false);
// 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 = GameLayer::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
我正在使用kResolutionNoBorder策略。 但您已準備好了解資產大小問題。我現在使用的是標準視網膜和非視網膜大小的資產,而且工作效果很好。歡呼 – IamRKhanna
使用kResolutionExactFit,事情會變得更好,但我會將其留給您的選擇。如果此答案解決了您的問題,請將其標記爲已接受,以便可以幫助其他人。 – Wajahat