Zookeeper
Some time ago cocos2dx updated the latest version of cocos2d-2.0-x-2.0.2, but also from this version has changed the policy for resource loading and management.
In the previous loading method is to follow the same way to load resources as cocos2d-iphone, for the image name after adding-HD,-iPad,-ipadhd, after you enable the project's HD retina, you can find the corresponding resources by default. But from the cocos2d-2.0-x-2.0.2 version, the Resource load policy does not. For more information about cross-platform integration, see cocos2dx's latest 2. x cross-platform integration ndk + xcode.
The latest resource loading policy mechanism is as follows:
First, find the directory set in setresourcedirectory of ccfileutils. If it cannot be found, find it in the resources/directory.
For example:
1) set the directory:
Ccfileutils: sharedfileutils ()-> setresourcedirectory ("ABC ");
When creating an genie:
Ccsprite * SPR = ccsprite: create(“himi.png ");
Cocos2dx first searches for “himi.png.pdf in the resources/abcdirectory. If it is not found, it will go back to the resourcesdirectory to find “himi.png ".
Therefore, we usually open the HD retina in the applicationdidfinishlaunching function of appdelegate. cpp and add the following code:
Targetplatform target = gettargetplatform (); // obtain the current device type
If (target = ktargetipad) {// if it is an iPad
If (pdirector-> enableretinadisplay (true) {// If HD retina is enabled
Ccfileutils: sharedfileutils ()-> setresourcedirectory ("../ipadhd ");
} Else {
Ccfileutils: sharedfileutils ()-> setresourcedirectory ("../iPad ");
}
} Else if (target = ktargetiphone) {// if it is an iPhone
If (pdirector-> enableretinadisplay (true ))
{
Ccfileutils: sharedfileutils ()-> setresourcedirectory ("../HD ");
}
The default directory of the Project is resources. The folders of HD, ipadhd, and iPad created here are at the same level as those of resources. Therefore, the directory is set ".. /HD ",".. /iPad ",".. /ipadhd"
Appendix:
The device enumerated variables are as follows:
Ktargetwindows: Window System
Ktargetlinux: Linux
Ktargetmacos: Mac OS
Ktargetandroid: Android system
Ktargetiphone: IOS-iPhone & itouch
Ktargetipad: IOS-iPad
Ktargetblackberry: BlackBerry System
The project directory is shown in 3.14.3.1:
The latest version of cocos2d 2. 0. X. 0.2 uses the new resource loading policy! -HD and ,-