Precautions for setting high definition mode for cocos2d-x 2.0.3 (removed-hd Mode)

Source: Internet
Author: User

Precautions for setting high definition mode for cocos2d-x 2.0.3 (removed-hd Mode)

2. after the hd mode is enabled before x, the underlying layer will automatically add-hd to the image name when the addImage is enabled. The-hd image is preferentially loaded. If the-hd mode is not enabled, the original image is loaded. (Ipad is-ipad, ipad HD is-ipadhd ).

2.0.3 has removed this mode (as if 2.0.2 was changed). 2. x then, the file management is written as a shared Singleton class: CCFileUtils: sharedFileUtils ();

When loading an image, the system will first locate the resource in getResourceDirectory () based on the image name. If not, locate the resource in the resource Directory.

For example, when the program starts, we set

CCFileUtils: sharedFileUtils ()-> setResourceDirectory ("HD ");

All loaded images will be searched under the resource/HD directory first. If not, they will be found in the resource Directory.

Therefore, when you enable the Retina hd mode, you cannot use the previous method to add the hd image suffix-hd. Instead, you should create a directory under the resource Directory to add a high-definition image.

In AppDelegate, enable the HD mode and set the priority to search for the image directory as resource/HD.

PDirector-> enableRetinaDisplay (true );

CCFileUtils: sharedFileUtils ()-> setResourceDirectory ("HD ");

Then, place the high-definition image in the resource/HD directory without the suffix-hd.

You can also obtain device information and set different directories based on different devices. Of course, if you do not want to put a high-definition image in resource, you can also.

For example: CCFileUtils: sharedFileUtils ()-> setResourceDirectory ("../HD ");

In this way, HD should be in the same directory as resource.


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.