1: 必要准备
1): jdk&jre
2): adt-bundle
3): android ndk r9
4): python2.7
5): cocos2d-x 3.0 alpha0
2: 依次安装或者解压
3: 添加/扩充环境变量
1): Path: C:\Python27;E:\android-ndk-r9
2): NDK_ROOT: E:\android-ndk-r9
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: 待续....