【问题标题】:Why is the content为什么是内容
【发布时间】:2016-11-25 05:30:29
【问题描述】:

在 AppDelegate.cpp 中,我们在 bool 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));

为什么我们取高度或宽度比率的最小值?为什么我们不总是采用 height 或 width ?这不会不一致吗?

由于我们使用的资产大小是固定的(例如,在每个区块中,我们选择大、中或小资产),不同纵横比的缩放比例是否不同,可能具有相同的高度或宽度?这不会导致更严重的问题,例如屏幕上的物理和图像不匹配吗?

【问题讨论】:

    标签: cocos2d-x cocos2d-x-3.0 cocos2d-x-3.x


    【解决方案1】:

    因为如果您选择最大比例,它将不适合高度/宽度(取决于方向)。

    例如设计分辨率960x640

    背景精灵的分辨率1024x768

    1024/960 * 1024 ≈ 1092 - 最大值

    640/768 * 1024 ≈ 853 - 分钟

    所以如果你选择最大你的背景会更宽然后设计和条纹 80 像素宽将超出屏幕。

    否则,您的背景将适合设计的宽度,旁边有一些黑色条纹 (960-853)/2 像素宽。

    Related information

    【讨论】:

      猜你喜欢
      • 2019-12-21
      • 1970-01-01
      • 2016-07-15
      • 1970-01-01
      • 2019-11-11
      • 2012-01-27
      • 2011-12-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多