平台
MacBook Pro (Retina,13-inch,Mid 2014)
2.6 GHz Intel Core i5
8 GB 1600 MHz DDR3
Xcode Version 6.3.2 (6D2105)
Python 2.7.9 (v2.7.9:648dcafa7e5f,Dec 10 2014,10:10:46)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
原料
下载最新cocos2d-x:
http://www.cocos2d-x.org/filedown/cocos2d-x-3.6.zip
解压到任意目录
生成新工程
用 Terminal 进入 /cocos2d-x-3.6/tools/cocos2d-console/bin 目录下,
CBD-MBP:bin baodong$ ls
CBD-MBP:bin baodong$ pwd
/Users/baodong/__TEST__/cocos2d-x-3.6/tools/cocos2d-console/bin
CBD-MBP:bin baodong$ ls -a
. cocos.bat cocos2d.ini cocos_stat.py
.. cocos.py cocos_project.py cocos_stat.pyc
cocos cocos.pyc cocos_project.pyc install.py
查看帮助文档
CBD-MBP:bin baodong$ python cocos.py new --help
usage: cocos new [-h] [-p PACKAGE_NAME] -l {cpp,lua,js} [-d DIRECTORY]
[-t TEMPLATE_NAME] [--ios-bundleid IOS_BUNDLEID]
[--mac-bundleid MAC_BUNDLEID] [-e ENGINE_PATH] [--portrait]
[--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,js},--language {cpp,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
--ios-bundleid IOS_BUNDLEID
Set a bundle id for ios project
--mac-bundleid MAC_BUNDLEID
Set a bundle id for mac project
-e ENGINE_PATH,--engine-path ENGINE_PATH
Set the path of cocos2d-x/cocos2d-js engine
--portrait Set the project be portrait.
lua/js project arguments:
--no-native No native support.
正式创建项目:
python cocos.py new -p cf.icbd.www -l cpp -d /Users/baodong/__TEST__/Cocos_TEST HelloCC
参数解释:
-p 包名
-l 项目所用语言『Cpp/Lua/JavaScript』
-d 项目存放路径
最后跟新项目名称
编译运行
进入 HelloCC/proj.ios_mac 目录
CBD-MBP:proj.ios_mac baodong$ ls -a
. .DS_Store ios
.. HelloCC.xcodeproj mac
用Xcode点击打开 HelloCC.xcodeproj
直接点击左上角运行即可。
速度比windows下速度快不少,几十秒内编译完成,自动启动模拟器。