cocos2d-x 3.11 游戏开发环境搭建流程

cocos2d-x 3.11.1 游戏开发环境搭建流程


1. 准备下面的软件

1) Windows7 64Bit+ VS2013 (VC++)

这个不用多说.

2) cocos2d-x-3.11.1.zip

# wget http://cocostudio.download.appget.cn/Cocos2D-X/cocos2d-x-3.11.1.zip

这个解压到目录下, 如: C:\DEVPACK\coscos2d-x

COCOS_CONSOLE_ROOT=C:\DEVPACK\cocos2d-x\cocos2d-x-3.11.1\tools\cocos2d-console\bin

3) tadp-4.0r2-windows.exe

# wget ftp://pub:[email protected]/gamedev/tadp-4.0r2-windows.rar

这个安装起来要一夜的时间. 安装路径:

Installation Directory: D:\NVPACK
Download Directory: D:\NVIDIA\TADP

4) jdk-7u80, maven

安装java, maven, 需要配置环境变量.

wget ftp://pub:[email protected]/gamedev/jdk-7u80-windows-x64.rar
wget ftp://pub:[email protected]/tarball/apache-maven-3.3.3-bin.tar.gz

5) Python2.7 for windows 64bits

wget ftp://pub:[email protected]/gamedev/python-2.7.11.amd64.msi
安装位置:

C:\python27

6) 设置环境变量

进入 C:\DEVPACK\cocos2d-x\cocos2d-x-3.11.1,运行:

cmd

python setup.py

会自动创建下面的环境变量。但是最好手工创建下面的变量,因为cocos2d-x的setup.py脚本还是有问题。

Windows管理环境变量的UI是真的很烂,没办法,手工创建:

DEVPACK_HOME=C:\DEVPACK
NVPACK_HOME=D:\NVPACK
NVPACK_ROOT=D:\NVPACK
JAVA_HOME=C:\DEVPACK\Java\jdk1.7.0_45
CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
ANDROID_HOME=D:\NVPACK\android-sdk-windows
ANDROID_SDK_ROOT=D:\NVPACK\android-sdk-windows
ANT_ROOT=D:\NVPACK\apache-ant-1.8.2\bin
ANT_HOME=D:\NVPACK\apache-ant-1.8.2
COCOS_X_ROOT=C:\DEVPACK\cocos2d-x
COCOS_CONSOLE_ROOT=C:\DEVPACK\cocos2d-x\cocos2d-x-3.11.1\tools\cocos2d-console\bin
COCOS_TEMPLATES_ROOT=C:\DEVPACK\cocos2d-x\cocos2d-x-3.11.1\templates
M2_HOME=C:\DEVPACK\apache-maven-3.0.5
NDK_ROOT=D:\NVPACK\android-ndk-r10d
NDKROOT=D:\NVPACK\android-ndk-r10d
ANDROID_NDK_ROOT=D:\NVPACK\android-ndk-r10d
Path=%COCOS_TEMPLATES_ROOT%;%COCOS_CONSOLE_ROOT%;%ANT_ROOT%\bin;%M2_HOME%\bin;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin

2. 创建项目

> cmd

> cd $COCOS_CONSOLE_ROOT

> cocos new game_stencil -p com.pepstack.dev -l cpp -d c:\workspace\gamedev

然后用VS2013打开:

C:\workspace\gamedev\game_stencil\proj.win32\game_stencil.sln

编译即可!

3. 编译android项目

cmd

cd C:\workspace\gamedev\game_stencil\proj.android

python build_native.py

报错:

......
At global scope:
cc1plus.exe: warning: unrecognized command line option "-Wno-extern-c-compat"
cc1plus.exe: warning: unrecognized command line option "-Wno-extern-c-compat"
make.exe: *** 拒绝访问。
.  Stop.
make.exe: *** Waiting for unfinished jobs....
make.exe: Leaving directory `c:/Workspace/gamedev/game_stencil/proj.android'
执行命令出错,返回值:2。
Traceback (most recent call last):
  File "build_native.py", line 43, in 
    build(opts.build_mode)
  File "build_native.py", line 28, in build
    raise Exception("Build dynamic library for project [ " + app_android_root +
" ] fails!")
Exception: Build dynamic library for project [ c:\Workspace\gamedev\game_stencil
\proj.android\../ ] fails!
换成 3.10版本仍然出错。重试各种方法,最后:

cmd
cd %COCOS_X_ROOT%\cocos2d-x-3.11.1
python setup.py
cd C:\workspace\gamedev\game_stencil\proj.android
python build_native.py
成功!

...
-post-build:

debug:

BUILD SUCCESSFUL
Total time: 13 seconds
正在移动 apk 文件 c:\Workspace\gamedev\game_stencil\bin\debug\android
编译成功。

核心就是编译前必须执行:

python setup.py

4 eclipse编译到Android平台

参考:

http://blog.csdn.net/ubuntu64fan/article/details/44040413

OK!


5 项目添加lua支持

参考:

http://www.cnblogs.com/marisa/p/4130469.html


你可能感兴趣的:(cocos2d)