Cocos2d-x 3.10 screen adaptation problem, cocos2d-x3.10

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.