1: 必要準備javascript
1): jdk&jrejava
2): adt-bundlepython
3): android ndk r9android
4): python2.7git
5): cocos2d-x 3.0 alpha0github
2: 依次安裝或者解壓python2.7
3: 添加/擴充環境變量curl
1): Path: C:\Python27;E:\android-ndk-r9函數
2): NDK_ROOT: E:\android-ndk-r9ui
3): NDK_MODULE_PATH: E:\cocos2d-x-3.0alpha0;E:\cocos2d-x-3.0alpha0\cocos2dx\platform\third_party\android\prebuilt
4: alpha0版本對於android版本的項目生成和編譯支持部完善.
須要去https://github.com/cocos2d/cocos2d-x的開發分支取最新的template項目模板,最重要是的build_native.cmd文件
5: 多平臺項目建立:
1): 必要軟件: python-2.7.3
2): 工程路徑中不要有漢字,全英文最好
3): CMD到cocos2dx的根目錄
4): 輸入命令行,格式爲:
python create-multi-platform-projects.py -p project_name -k com.your_company -l cpp
Options:
-l Language:語言
-l cpp for a cocos2d-x C++ project
-l lua for a cocos2d-x + Lua bindings project
-l javascript for a cocos2d-x + JavaScript bindings project
5): 成功後再.\projects\下面有建立一個叫作<project_name>的完整項目
6: Android.mk修改,修改成自動掃描Classes文件夾,不用後期頻繁修改:
1 LOCAL_PATH := $(call my-dir) 2 3 include $(CLEAR_VARS) 4 5 LOCAL_MODULE := cocos2dcpp_shared 6 7 LOCAL_MODULE_FILENAME := libcocos2dcpp 8 9 # 遍歷目錄及子目錄的函數 10 define walk 11 $(wildcard $(1)) $(foreach e, $(wildcard $(1)/*), $(call walk, $(e))) 12 endef 13 14 # 遍歷Classes目錄 15 ALLFILES = $(call walk, $(LOCAL_PATH)/../../Classes) 16 17 FILE_LIST := hellocpp/main.cpp 18 # 從全部文件中提取出全部.cpp文件 19 FILE_LIST += $(filter %.cpp, $(ALLFILES)) 20 21 LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) 22 LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes 23 24 LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static 25 LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static 26 # LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static 27 LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static 28 LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static 29 30 include $(BUILD_SHARED_LIBRARY) 31 32 $(call import-module,cocos2dx) 33 $(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) 34 $(call import-module,CocosDenshion/android) 35 $(call import-module,extensions) 36 # $(call import-module,external/Box2D) 37 $(call import-module,cocos2dx/platform/android)
7: 進入控制檯,切換到$./proj.android/目錄下面: 執行build_native.cmd命令.等待結果~
8: 待續....