1,版本参考
所谓的quick就是指coco2d-lua
coco2d版本很多,开发环境有很多,参考资料的时候要注意本版和环境问题,最好跟着官方文档走;
2,环境搭建
E:\Cocos\quick-3.5 coco2d-lua运行环境
E:\Cocos\Sublime Text 2+quickxdev 编码环境
E:\Cocos\Python27 python环境
E:\Cocos\android-ndk-r9d ndk环境
E:\Cocos\sdk adk环境
E:\Cocos\apache-ant-1.9.6 ant环境
C:\Program Files\Java\jdk1.7 java环境
需要配置环境变量
NDK_ROOT
E:\Cocos\android-ndk-r9d
NDK_ROOT
E:\Cocos\android-ndk-r9d
ANT_HOME
E:\Cocos\apache-ant-1.9.6
ANT_ROOT
E:\Cocos\apache-ant-1.9.6\bin
ANDROID_SDK
E:\Cocos\sdk
ANDROID_SDK_ROOT
E:\Cocos\sdk
Path
E:\Cocos\quick-3.5\templates;E:\Cocos\quick-3.5\tools\cocos2d-console\bin;;E:\Cocos\Python27;E:\Cocos\apache-ant-1.9.6\bin
E:\Cocos\sdk\platform-tools;E:\Cocos\sdk\tools;
COCOS_CONSOLE_ROOT
E:\Cocos\quick-3.5\tools\cocos2d-console\bin
COCOS_TEMPLATES_ROOT
E:\Cocos\quick-3.5\templates
CLASSPATH
.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
JAVA_HOME
C:\Program Files\Java\jdk1.7.0_79
补充一点:
quick-3.5环境快速配置,只需要执行E:\Cocos\quick-3.5\setup.py就可以
执行方法:先配置好python环境,然后命令提示符cmd下面执行以下命令:
python E:\Cocos\quick-3.5\setup.py
3,ant打包lib
打包F:\TLStar\apk\libs\umeng-analytics-v5.5.3.jar
需要这么做
F:\TLStar\frameworks\runtime-src\proj.android\build.xml文件添加
然后再custom_rules.xml文件中添加对应的jar
<?xml version="1.0" encoding="UTF-8"?>
<project
name="custom_rules"
default="release" >
<target name="-pre-compile" >
<echo message="JARPATH=${toString:project.all.jars.path}" >
</echo>
<property
name="umeng.analytics.dir"
value="F:/TLStar/apk/libs/umeng-analytics-v5.5.3.jar" >
</property>
<path id="umeng.analytics" >
<path path="${toString:project.all.jars.path}" >
</path>
<pathelement location="${umeng.analytics.dir}" >
</pathelement>
</path>
<path id="project.all.jars.path" >
<path refid="umeng.analytics" >
</path>
</path>
<echo message="JARPATH=${toString:project.all.jars.path}" >
</echo>
</target>
</project>
4,assert资源文件打包
比如将F:\TLStar\apk\assets下面的a.xml打包到assets下
F:\TLStar\frameworks\runtime-src\proj.android\build-cfg.json文件中添加代码
“must_copy_resources”: [
{
“from”: “../../../apk/assets”,
“to”: “”
}
]
5,so文件的拷贝
要拷贝的so文件是
F:\TLStar\frameworks\runtime-src\proj.android\jni\prebuilt\a.so;
F:\TLStar\frameworks\runtime-src\proj.android\jni\prebuilt\b.so;
F:\TLStar\frameworks\runtime-src\proj.android\jni\prebuilt\c.so
在Android.mk文件中添加如下代码
include $(CLEAR_VARS)
LOCAL_MODULE := a
LOCAL_SRC_FILES := prebuilt/liba.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := b
LOCAL_SRC_FILES := prebuilt/libb.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := c
LOCAL_SRC_FILES := prebuilt/libc.so
include $(PREBUILT_SHARED_LIBRARY)
6,几个cocos命令
创建工程(res和src可以直接替换成你自己的)
python cocos.py new TLStar -p com.tl.star -l lua -d ~/proj
编译android版本
cocos compile -m release -p android
编译win32版本
cocos compile -m release -p win32
编译运行android版本
cocos run -p run android
编译运行win32版本
cocos run -p win32