首页 > 代码库 > cocos2d_x_01_环境搭建

cocos2d_x_01_环境搭建

Cocos2d-x-3.3 Mac 安装
下载地址:



参考文档: 



在线API列表: 

Cocos2d-x-3.3 版本
配置安装创建项目都是命令行
  • 官网下载最新版本Cocos2d-x-3.3,大小约为280M 

    • 解压后,在【终端】中切换目录到 解压后的目录,然后执行./setup.py,回车,如下图所示.
    • 期间会有几次询问,是否要设置安卓SDK路径,
    • 如果尚未安装Android开发环境,可以直接Enter跳过,暂不设置
    • (将来  可以在下面的文件中,进行配置:/etc/profile)

1
2
3
 ->Please enter the path of NDK_ROOT (or press Enter to skip):
 ->Please enter the path of ANDROID_SDK_ROOT (or press Enter to skip):
 ->Please enter the path of ANT_ROOT (or press Enter to skip):


根据提示,敲击命令:
source /Users/history/.bash_profile
然后Enter,这样就算设置好了.

1
Please execute command: "source /Users/history/.bash_profile" to make added system variables take effect


  • 最后就是创建工程.
  • 继续命令行
  • cd tools/cocos2d-console/bin,
  • 接着使用下面命令即可:
  • cocos new 工程名 -p 包名 -l 语言 -d 目标文件夹,
  • 例如 :
  • cocos newcocos2d_x -pcom.beyond -lcpp -d /Users/beyond/Desktop/project


  • 执行后就有如下提示,表示OK~
1
2
3
4
5
6
Running command: new
> Copy template into /Users/beyond/Desktop/project/cocos2d_x
> Copying cocos2d-x files...
> Rename project name from ‘HelloCpp‘ to ‘cocos2d_x‘
> Replace the project name from ‘HelloCpp‘ to ‘cocos2d_x‘
> Replace the project package name from ‘org.cocos2dx.hellocpp‘ to ‘com.beyond‘


打开自动创建好的项目
可以选择桌面应用,直接command+R,编译运行


等了n分钟过后,终于跑出来了~

后续补充一下:NDK目录的配置
进入终端,输入命令:sudo nano /etc/profile
打开配置环境变量的文件


根据实际情况,添加NDK_ROOT、ANT、SDK目录
最终,示例如下:









cocos2d_x_01_环境搭建