Cross-platform coocs2d-x Compilation

Source: Internet
Author: User

Cross-platform coocs2d-x Compilation

1. File Path Problems. To implement cross-platform processing, we need to manage the file path strength of different ides. In VS, code management is completely managed based on the physical path, and the remaining part is the resource path problem. In the version above the win7-vs2012 (vs110_xp corresponding version settings to search again, the past tool should give up) You can choose the value of Working Directory in Debugging from $ (ProjectDir) set to $ (ProjectDir ).. /Resources. However, this requires that the file ing be modified simultaneously on the mac working platform each time resources are added or file names are modified.

To discard the single platform management method above, the cocos team added the file management tool FileUtils to the engine. We only need to add a sentence in the Code:

 

AppDelegate::AppDelegate() {    FileUtils::getInstance()->addSearchPath(../Resources,true);}

In this way, Resources in the Resources folder are preferentially searched for each search path.

 

The rest is the code file organization of Android and Mac.

Mac environment:

Create a group in Xcode that corresponds to the same physical file name, and then pull the files under the folder into the project file tree. Select folder references. Or try to directly introduce the project in the form of folder references in the entire folder (not tried ).

Folder references: maintains the original physical structure of the path, so that it can be applicable to the uniform header file path of multiple platforms.

Group: a virtual path similar to the vs file filter. If this method is introduced, the path of the file relative to the project is the same level, that is, the file is in the same parent directory.

 

Android environment:

Modify the resource path in build_native.py:

 

Def copy_resources (app_android_root): # remove app_android_root/assets if it exists assets_dir = OS. path. join (app_android_root, assets) if OS. path. isdir (assets_dir): shutil. rmtree (assets_dir) # copy resources OS. mkdir (assets_dir) resources_dir = OS. path. join (app_android_root,) ''' removes the original path if OS. path. isdir (resources_dir): copy_files (resources_dir, assets_dir)


 

This increases the search time logically. In fact, you can manually read a configuration file under the configuration Resources folder and set the real resource path based on the platform. Then, only this unique path is used for file path search, which reduces the time for path testing in FileUtils.

 

2. prefix head problems. Delete the paths generated by cocos in Xcode6, or compare the testCpp configuration file to find that the prefix head option is empty for ios and mac projects.

 

 

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.