Cocos2d-x 3.10 screen adaptation problem, cocos2d-x3.10
Cocos2d-x screen adaptation problem has plagued me for a long time, there is almost a license. The problem is solved through hands-on practice. Share the solution for your reference.
In fact, the solution is very simple. Just comment out the following code.
1 // if (frameSize.height > mediumResolutionSize.height) 2 // { 3 // director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width)); 4 // } 5 // // if the frame's height is larger than the height of small size. 6 // else if (frameSize.height > smallResolutionSize.height) 7 // { 8 // director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width)); 9 //}10 // // if the frame's height is smaller than the height of medium size.11 // else12 // { 13 // director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));14 //}
Yes, this is the code that the cocos2d-x generates for us, and a lot of information says it's used
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
However, if setDesignResolutionSize () is used when the first part of the code is not commented out, screen adaptation cannot be completed, but it is larger than not used.
Some documents also said that the first part and the second part of the Code should be used in combination, but I did not have the effect, but it was just a comment.
Anyway, there are three possibilities for screen adaptation (using the first part of code, using the second part of code, and using the two parts of Code together, don't ask me why I don't mention the use of both parts of the Code.) I am not saying that my approach is correct. Other people's approach is wrong. developers should try these three situations, there should always be one that suits you.
I contact cocos2d-x time is not long, the shortcomings, please pointed out