资源列表
- 官网上下载最新的cocos2d-x-3.3。
- 安装JDK,Eclipse,CDT插件,ADT插件。
- 下载Android SDK,更新。因为国内经常访问不了google,用vpn速度也有点慢。网上搜来的ip还可以用,改hosts文件。210.242.125.108 dl-ssl.google.com
- 下载NDK。
- 下载ANT。
- 安装VS2013。
- 安装python 2.7。
最终环境是:
- VS2013;
- python 2.7.8;
- ant-1.9.4;
- cocos2d-x-3.3;
- Eclipse Luna Service Release 1 (4.4.1);
- CDT 8.5.0;
- Android NDK, Revision 10;
- JDK (Java SE 8u25).
PC环境开发
命令行到cocos2d-x-3.3的目录,执行setup.py,填好ANT、NDK、SDK的安装/解压目录,结束。
用setup.py配置好Cocos2d-x的环境之后,你的命令行中就会多如“cocos”的命令,新建项目将使用这个命令进行。示例:
1 cocos new hello(项目名称)-p com.hello(包名字)-l cpp(项目类型) -dF:\(目录)
进入项目目录,结构如图。
进入proj.win32,打开.sln文件(会自动关联vs2013),编译之后应该可以运行。
在这里卡了一段时间,因为实验室的机器没有独显,带的集显又不支持OpenGL,所以glfwCreateWindow返回值为null。
无奈在自己笔记本搭建环境,一步到位。
Android环境开发
eclipse的ADT插件可以导入android项目,然后run as android application就行。
模拟器的话,用2.3.3的虚拟机不能启动,会报错。java.lang.IllegalArgumentException: No configs match configSpec
主要原因见stackoverflow。
This is actually part of a bigger issue, and I‘m hoping that by posting here, others who have experienced this error will read this entry. I equally hope that, if any of my conclusions are incorrect, someone comes forth with a more definitive explanation and/or solution.
The core issue is OpenGL support. Beginning at 2.2, Android supports OpenGL ES 2.0, and beginning at 4.0.3, Android emulators support OpenGL ES 2.0. Code that uses OpenGL ES 2.0 will not work on emulators before 4.0.3. [Evidently, the camera switched from ES 1.0 to 2.0 at Android 2.2]
But that‘s not all! None of the Android docs I‘ve encountered mention that, in order to support Open GL ES 2.0 emulation, your box‘s graphic card chipset and driver must support OpenGL 2.0 as well. Therefore, if you enable GPU Emulation on the AVD and you still encounter this error, do the following:
- Find out the specs on your graphic card and visit the chipset manufacturer‘s web site to determine if the chipset is OpenGL 2.0 compatible. If it isn‘t, you‘re S.O.L. and must stick to debugging through an actual Android device instead of an emulator.
- Determine if you have the latest graphics driver for the chipset. Drivers obtained through Microsoft (if you‘re using Windows) typically do not support OpenGL, so you want to download the latest driver from the manufacturer.
我用了真机(HTC G10)可以跑起来;