In AppDelegate.cpp , we have the following code in 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));
Why do we take the MIN of the ratios of the height or width ? Why don't we always take either the height or the width ? Won't this be inconsistent?
Since the assets we use are fixed in size (for example, in each block we either pick the large, medium or small assets), isn't the scaleing different for different aspect ratios, that may have the same height or width ? Wouldn't this lead to even worse problems like the physics and images on screen not matching ?