这里是Cocos2dx初学者。使用Cocos2dx V3.10。
我读过很多关于跨iOS/Android等多平台支持的教程和文档,主要是我明白了。我正在结合使用setDesignResolutionSize和setContentScaleFactor,到目前为止,它运行得很好。
我确实有一个问题,我不确定如何才能最好地解决它。
我的游戏是肖像,我想要一个特殊的雪碧在iphone4s和iphone5上的宽度相同。
它们都使用相同的设计分辨率、大小和内容比例因子,但在iphone4上,sprite比iphone4 (和iphone5)要小。
我附上了两张图片来说明我的意思。


正如您在iphone4上看到的那样,sprite离边缘的距离与iphone5的距离并不完全相同,我认为这是由于分辨率的差异造成的。
我是否需要为这个决议创建另一套资产,我将如何设置这些资产?由于目前iphone4和iphone5都使用相同的规模和设计大小,即:
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
Size frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
searchPaths.push_back("hd");
FileUtils::getInstance()->setSearchPaths(searchPaths);
}任何帮助都很感激。
发布于 2016-04-18 06:42:18
这可以在某种程度上做到,无论你使用什么设备,游戏看起来都是一样的。首先,注释掉AppDelegate.cpp中的所有代码
/* if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height)
{
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium sxize.
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
*/现在,请确保您的所有资产都是参照画布大小开发的,这是理想的背景大小。
假设这个大小是customWidth x customHeight。
现在在AppDelegate.cpp中编辑以下行,如下所示:
glview->setDesignResolutionSize(customWidth, customHeight, ResolutionPolicy::EXACT_FIT);
Size frameSize = glview->getFrameSize();不管设备是什么,你的游戏现在看起来都一样,只要保持高宽比(所有手机都一样,平板电脑就不同了)。
https://stackoverflow.com/questions/36675732
复制相似问题