1
在AppDelegate.cpp,我们在布尔AppDelegate::applicationDidFinishLaunching()
下面的代码:为什么内容
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::SHOW_ALL);
auto 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));
//Add Code to use large assets
}
// 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));
//Add Code to use medium assets
}
// if the frame's height is smaller than the height of medium size.
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
//Add Code to use small assets
}
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
为什么我们采取高度或宽度的比值的MIN?为什么我们不总是采取高度或宽度?这不会不一致吗?
由于我们使用的资产的大小是固定的(例如,在每个区块中,我们选择大型,中型或小型资产),对于不同的纵横比率,缩放比例不同,可能具有相同的高度或宽度?这不会导致更糟糕的问题,如屏幕上的物理和图像不匹配吗?