1. 下载cocos 2d 3.0 zip
2. 解压后找到文件readme.md
3. 跟随指导
3.1
先假设我在mac里的登录用户名是xx,所以文档目录就应该是 /Users/xx/Documents
在终端命令行中输入
$ cd cocos2d-x
$ python download-deps.py
等待下载
下载完成后,提示是否删除已经下载的zip,我选no
readme这么写
$ cd cocos2d-x
$ ./setup.py
$ source FILE_TO_SAVE_SYSTEM_VARIABLE
$ cocos new MyGame -p com.your_company.mygame -l cpp -d NEW_PROJECTS_DIR
$ cd NEW_PROJECTS_DIR/MyGame
我在终端里面写
$ cd cocos2d-x
$ ./setup.py
运行setup.py的时候提示
->Configuration for Android platform only,...
我暂时不需要,统统跳过
最后一条提示是:
Please execute command: "source /Users/xx/.bash_profile" to make added system variables take effect
那么,我就根据这一条输入命令
source /Users/xx/.bash_profile
然后没有任何回应,这就可以了?再根据readme往下
现在是从模版生成工程文件
cocos new MyGame -p com.mycompany.mygame -l cpp -d /Users/xx/Documents/Code
提示
Running command: new
> Copy template into /Users/xx/Documents/Code/MyGame
> Copying cocos2d-x files...
> Rename project name from 'HelloCpp' to 'MyGame'
> Replace the project name from 'HelloCpp' to 'MyGame'
> Replace the project package name from 'org.cocos2dx.hellocpp' to 'com.mycompany.mygame'
现在可以进入/Users/xx/Documents/Code/MyGame查看工程了
在控制台上输入cocos run -p mac 就能运行了
如果是android系统则要指定版本
cocos run -p android --ap 20