Cocos2d-x latest 2.1.0 version Problems

Source: Internet
Author: User

It was a few months ago that cocos2dx was last played. Today, I went to the official website to check that the stable version 2.0.3 is available and the beta version 2.1.0 is available. So I cloned a code 2.1.0 on github and upgraded it to the latest version. First, upgrade the Xcode template. Is ~ /Library/Developer/Xcode/Templates cocos2d-x removed, then run the cocos2d-x under the install-templates-xcode.sh root directory and then talk about the android environment (Mac/Linux ). Mainly look at the next few script files. 1. cocos2d-x script under the create-android-project.sh root directory this script requires the path of the sdk and ndk. However, you do not need to change this script because it will retrieve global environment variables. Therefore, you only need to add the environment variable [cpp] export ANDROID_SDK_ROOT = ~ in bash_profile ~ /Workspace/android-sdk-macosx export ANDROID_NDK_ROOT = ~ /Workspace/android-ndk-r8b export COCOS2DX_ROOT = ~ /Workspace/cocos2d-x export NDK_ROOT = ~ /Workspace/android-ndk-r8b export PATH = $ PATH: $ ANDROID_SDK_ROOT export PATH = $ PATH: $ ANDROID_NDK_ROOT export ANDROID_SDK_ROOT = ~ /Workspace/android-sdk-macosxexport ANDROID_NDK_ROOT = ~ /Workspace/android-ndk-r8bexport COCOS2DX_ROOT = ~ /Workspace/cocos2d-xexport NDK_ROOT = ~ /Workspace/android-ndk-r8bexport PATH = $ PATH: $ ANDROID_SDK_ROOTexport PATH = $ PATH: $ ANDROID_NDK_ROOT is set as its own PATH. This script mainly does two things 1. creating an android project is called android. android commands under sdk/tools/. For details, refer to Google DOCUMENTATION 2. call the copy_files.sh script under template/android/to copy the file and make some modifications to the project, such as modifying AndroidManifest. xml. Let's take a look at the copy_files.sh script, which is a series of copies, such as copying resource files, java files, and modifying AndoirdManifest. xml. The two scripts are mainly used. The problem is that the previous 2.0.1 version has a HelloWorld under the root directory. Run the create-android-project.sh script to create a new project, its initial java file jni, which is all copied from this HelloWorld project. Then there are some changes to version 2.1.0. Version 2.1.0 includes helloworld, tests, and some Lua and javascript demos in the samples directory. \ Running the create-android-project.sh in the root directory of version 2.1.0 to generate a new project may cause problems. AndoridManifest. xml is an empty file and cannot be compiled with ant. I checked its script and found that copy_files.sh had a surprise [cpp] HELLOWORLD_ROOT = $ COCOS2DX_ROOT/samples/HelloCpp HELLOWORLD_ROOT = $ COCOS2DX_ROOT/samples/HelloCpp, which is the defined HelloWorld path, this path is incorrect, with fewer Cpp entries. Therefore, you need to change the value to the following: [cpp] HELLOWORLD_ROOT = $ COCOS2DX_ROOT/samples/Cpp/HelloCpp HELLOWORLD_ROOT = $ COCOS2DX_ROOT/samples/Cpp/HelloCpp. Therefore, the helloworld directory is, hey. Let's look at the copy_src_and_jni () function, which copies the src and jni files in the HellWorld directory. This script is different from version 2.0.1. 2.0.1 first calls the copy_src_and_jni () function to copy the src and jni directories, and then calls copy_library_src () to copy the java files under cocos2dx/platform/android/java/src_common. 2.1.0 does not have the copy_library_src () function, that is, it does not copy the java file under platform. How is it done. There is a line in the create-android-project.sh [cpp] $ ANDROID_SDK_ROOT_LOCAL/tools/android update project-l .. /.. /cocos2dx/platform/android/java-p $ PROJECT_DIR/proj. android $ ANDROID_SDK_ROOT_LOCAL/tools/android update project-l .. /.. /cocos2dx/platform/android/java-p $ PROJECT_DIR/proj. android uses the java file in platform as the library of the new project. Therefore, if you use eclipse, you can also make java under platform into a library project. But I tried to use ant to compile it in the command line. I don't know if it is a build. xml problem generated after the updata project. I am a little bit confused. Please advise. So I changed him to the same method as 2.0.1. 1. comment out the above sentence, that is, add a #2. Modify the HELLOWORLD_ROOT path of the copy_files.sh script at the beginning of the line, as shown below:

3. Modify the copy_files.sh script. Add a row to the cop_src_and_jni () function,

After finishing, close the job.

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.