一、创建可以同时运行在xcode和eclipse的项目:
1.
打开mac终端,进入cocos2d-x目录下的tools/project-creator,执行命令
./create_project.py -project [项目名] -package [包名] -language [使用语言cpp或java等]
然后就能在cocos2d-x目录下的projects中看到新生成的项目了。
2.把创建的项目放在D:\cocos2d\cocos2d-x-2.1.4\projects目录下,如果没有projects文件夹可以创建一个
3.导入android项目proj.android
4.导入cocos2d-x库文件 D:\cocos2d\cocos2d-x-2.1.4\cocos2dx\platform\android\java\src下文件到项目src目录下,刷新一下项目可以看见导入的包了。
5.选择对应设备的sdk:选中项目,右键选择properties->Android,选择sdk版本ok保存.
6.在AndroidManifest.xml里面对应的版本信息
7.设置环境变量NDK_MODULE_PATH := D:\cocos2d\cocos2d-x-2.1.4;D:\cocos2d\cocos2d-x-2.1.4\cocos2dx\platform\third_party\android\prebuilt
8.设置Tool Chain Editor: Current toolchain = No ToolChain; Current builder = Android Builder
9. jni文件夹,添加:
windows下
NDK_MODULE_PATH := D:\cocos2d\cocos2d-x-2.1.4;D:\cocos2d\cocos2d-x-2.1.4\cocos2dx\platform\third_party\android\prebuilt
APP_CFLAGS += -Wno-error=format-security
mac下
NDK_MODULE_PATH := /Users/eachbaby3/Documents/cocos2d-x/cocos2d-x-2.1.4;/Users/eachbaby3/Documents/cocos2d-x/cocos2d-x-2.1.4/cocos2dx/platform/third_party/android/prebuilt
APP_CFLAGS += -Wno-error=format-security
到Application.mk
10.从项目资源包中导入资源到assets文件夹,刷新一下。
二、移植从xcode完成的项目到eclipse(步骤同上2-10相同)
1.修改Android.mk文件
添加cocos2d路径
$(call import-add-path,$(LOCAL_PATH)/platform/third_party/android/prebuilt)
$(call import-add-path, /Users/eachbaby3/Documents/cocos2d-x/cocos2d-x-2.1.4)\
$(call import-add-path, /Users/eachbaby3/Documents/cocos2d-x/cocos2d-x-2.1.4/cocos2dx/platform/third_party/android/prebuilt)\
MY_CPP_LIST := $(wildcard $(LOCAL_PATH)/*.cpp)
MY_CPP_LIST += $(wildcard $(LOCAL_PATH)/hellocpp/*.cpp)
MY_CPP_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
LOCAL_SRC_FILES := $(MY_CPP_LIST:$(LOCAL_PATH)/%=%)
2.修改Makefile文件的主类名称
3.选择c/c++ general->code Analysis模式为use project settings,取消所有被选中状态的BUG
从1024到960缩小倍 0.9375