1. 用xcode建立cocos2d-x的ios project
2. 建立android用的cocos2d-x project
3. 把android project中的"Resource"跟"android"兩個目錄搬到xcode專案的目錄下 (跟Classes同一層)
4. 修改android目錄中的build_native.sh, 將GAME_ROOT改成../
5. 在build_native.sh最後一行
$ANDROID_NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT $* 之後加上"COCOS2DX_ROOT=$COCOS2DX_ROOT"
6. 修改jni/Android.mk, 將subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \
cocos2dx \
CocosDenshion/android \
))
中的"$(LOCAL_PATH)/../../.." 改為$(COCOS2DX_ROOT) (最後一個/不要去掉!)
7. 修改jni/Helloworld/Android.mk, 將
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../cocos2dx \
$(LOCAL_PATH)/../../../../cocos2dx/platform \
$(LOCAL_PATH)/../../../../cocos2dx/include \
$(LOCAL_PATH)/../../../../CocosDenshion/include \
$(LOCAL_PATH)/../../../../cocos2dx/include \
$(LOCAL_PATH)/../../../../CocosDenshion/include \
紅色的部份都改成$(COCOS2DX_ROOT) (最後一個/不要去掉!)
以及
LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../../libs/armeabi) \
-lcocos2d -llog -lcocosdenshion \
-L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl
-lcocos2d -llog -lcocosdenshion \
-L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl
橘色部份改成$(COCOS2DX_ROOT)(最後一個/不要去掉!)
這樣應該compile應該就沒問題了, android專案也不會被cocos2d-x專案位置綁住 (若有修改則修改build_native.sh即可)
Resource的部份, 因為build_native.sh會把Resource/中的所有資料複製到asset中, 所以resource必須要放在這裡, 用ln -s 跟Resources (ios用)中的目錄作連結便可以很方便地同步資料