All articles on this site areLi huaming himiOriginal, reprinted must be explicitly noted:
Reprinted from[Heimi gamedev block]Link: http://www.himigame.com/cocos2dx-v2-0/997.html
☞Click to subscribe☜The latest developments in this blog! Notify you of the latest blog in time!
Some time ago, cocos2dx updated the latest version cocos2d2.0x2.0.2, and changed the policy for resource loading and management from this version.
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. However, since cocos2d2.0x2.0.2, the resource loading policy does not.
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 iPad if (pdirector-> enableretinadisplay (true )) {// If HD retina ccfileutils: sharedfileutils ()-> setresourcedirectory (".. /ipadhd ");} else {ccfileutils: sharedfileutils ()-> setresourcedirectory (".. /iPad ") ;}} else if (target = ktargetiphone) {// for 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 by himi are the same 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 himi project directory is shown in 3.14.3.1:
Figure 3.14.3.1 project directory