In cocos2d-x 2. x, the iphone device's Retina hd mode is no longer the original-hd suffix after the hd image.
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
[Cpp]
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.
[Cpp]
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:
[Cpp]
CCFileUtils: sharedFileUtils ()-> setResourceDirectory ("../HD ");
In this way, HD should be in the same directory as resource.