Cocos2d-x development method under MAC-code sharing between xcode and eclipse

Source: Internet
Author: User
========================================================== =============================== Original blog, for reprinting, please declare the source of e-coffee-Focus on mobile Internet ==================================== ====================================

These days suddenly there was a think good game electronics, intends to use cocos2d-x in iOS and Android at the same time.

I used to write two cocos2d games in the past. Currently, cocos2dx is not difficult.

Android and iOS share the resources of classes and resources, maintain a set of C/C ++ code, rather than copying various resources in the xcode and eclipse projects.

According to the official documentation, the android helloworld was created under the cocos2d-x SDK, And the helloworld was also created in the xcode project.

Run OK.

Copy proj. Android under the android project to the IOS project.

Eclipse imports the new Android project. Run the command line CD to proj. Android and run sh build_native.sh. An error is returned:

Dk_root =/users/yangeric/android-ndk-r8dCOCOS2DX_ROOT =/users/yangeric/MIOs/ccxtext/proj. android /.. /.. // --- this path is not app_root =/users/yangeric/MIOs/ccxtext/proj. android /.. app_android_root =/users/yangeric/MIOs/ccxtext/proj. androidusing prebuilt externalsmake: Entering directory '/users/yangeric/MIOs/ccxtext/proj. android '/users/yangeric/android-ndk-r8d/build/CORE/Add- Application. MK: 128: Android ndk: Warning: app_platform Android-9 is larger than Android: minsdkversion 8 in. /androidmanifest. XML Android ndk: Warning: Ignoring unknown import Directory:/users/yangeric/MIOs/ccxtext/proj. android /.. /.. /cocos2dx/platform/third_party/Android/prebuilt Android ndk: JNI/android. MK: cannot find module with Tag 'cosdenshion/android' in import path Android ndk: Ar E you sure your ndk_module_path variable is properly defined? Android ndk: The following directories were searched: Android ndk: JNI/Android. mk: 19: *** Android ndk: Aborting... Stop.

Configuration path Sudu VI ~ /. Bash_profile

Add attribute

export COCOS2DX_ROOT=/Users/yangeric/cocos2d-2.1beta3-x-2.1.0

And modify build_native.sh to delete the row.

// Cocos2dx_root = "$ DIR/.../.." // The environment variable is configured. You do not need to specify

Re-run sh build_native.sh, OK, and run eclipse.

From then on, we only need to use xcode to edit the C ++ code, and then eclipse will compile and run it directly.

For the first time engaged in cocos2d-x, may not understand the place, please also point out.

-----

Record the path of. bash_profile.

export ANDROID_SDK_ROOT=/Applications/adt-bundle-mac-x86_64-20130219/sdkexport ANDROID_NDK_ROOT=/Users/ericyang/android-ndk-r8dexport COCOS2DX_ROOT=/Users/ericyang/cocos2d-2.1beta3-x-2.1.0export NDK_ROOT=/Users/ericyang/android-ndk-r8dexport PATH=$PATH:$ANDROID_SDK_ROOTexport PATH=$PATH:$ANDROID_NDK_ROOT

Related Article

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.