一、下载资源工具
1、下载cocos2d-x 3.0 官网地址:http://www.cocos2d-x.org/filedown/cocos2d-x-3.0-cn
2、下载VS2012 地址网上搜一下很多
3、下载adt-bundle-windows 和 ndk (NDK据说要下载最新的r9d版本)
4、下载ant 官网:http://ant.apache.org/
5、下载python 2.7 ,新版本多人说不合用
二、开始操作
1、安装软件 VS2012 、 sdk、 ndk 、 ant 、 python
2、cocos2d-x 3.0 直接解压到指定目录即可,无需安装
3、配置环境变量:jdk 环境变量、NDK_ROOT 、ANDROID_SDK_ROOT、ANT_ROOT
将ant bin 和 python bin 添加到path路径中,方便使用
4、运行cocos2d-x-3.0 下的setup.py 初始化检查cocos2d-x环境变量
三、常用指令
1、cocos new 创建工程
usage: cocos new [-h] [-p PACKAGE_NAME] -l {cpp,lua,js} [-d DIRECTORY]
[-t TEMPLATE_NAME] [--no-native]
[PROJECT_NAME]
Creates a new project
positional arguments:
PROJECT_NAME Set the project name
optional arguments:
-h, --help show this help message and exit
-p PACKAGE_NAME, --package PACKAGE_NAME
Set a package name for project
-l {cpp,lua,js}, --language {cpp,lua,js}
Major programming language you want to use, should be
[cpp | lua | js]
-d DIRECTORY, --directory DIRECTORY
Set generate project directory for project
-t TEMPLATE_NAME, --template TEMPLATE_NAME
Set the template name you want create from
lua/js project arguments:
--no-native No native support.usage: cocos new [-h] [-p PACKAGE_NAME] -l {cpp,lua,js} [-d DIRECTORY]
[-t TEMPLATE_NAME] [--no-native]
[PROJECT_NAME]
Creates a new project
positional arguments:
PROJECT_NAME Set the project name
optional arguments:
-h, --help show this help message and exit
-p PACKAGE_NAME, --package PACKAGE_NAME
Set a package name for project
-l {cpp,lua,js}, --language {cpp,lua,js}
Major programming language you want to use, should be
[cpp | lua | js]
-d DIRECTORY, --directory DIRECTORY
Set generate project directory for project
-t TEMPLATE_NAME, --template TEMPLATE_NAME
Set the template name you want create from
lua/js project arguments:
--no-native No native support.
2、使用 cocos compile 编译工程
usage: cocos new [-h] [-p PACKAGE_NAME] -l {cpp,lua,js} [-d DIRECTORY]
[-t TEMPLATE_NAME] [--no-native]
[PROJECT_NAME]
Creates a new project
positional arguments:
PROJECT_NAME Set the project name
optional arguments:
-h, --help show this help message and exit
-p PACKAGE_NAME, --package PACKAGE_NAME
Set a package name for project
-l {cpp,lua,js}, --language {cpp,lua,js}
Major programming language you want to use, should be
[cpp | lua | js]
-d DIRECTORY, --directory DIRECTORY
Set generate project directory for project
-t TEMPLATE_NAME, --template TEMPLATE_NAME
Set the template name you want create from
lua/js project arguments:
--no-native No native support.
四、错误
在编译的时候,发现总算编译出错。发现时ndk所在目录为D:\Program Files 下因为路径中有空格,编译命令执行时总是出错,将ndk的地址更换后,正常编译