按我的知识,使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