The latest version of cocos2d 2. 0. X. 0.2 uses the new resource loading policy! -HD and ,-

Source: Internet
Author: User

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 ,-

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.