cocos2d-x 3.x Mac環境下搭建, 建立Xcode項目,cocos2d-xxcode
最近比較閑..折騰一下cocos2d-x 3.x系列。
雖然出來很久了,不過一直沒時間學習。之前一直用著2.14版本。
cocos2d v3.x 版本出來後,從配置安裝到建立項目都是命令列,下面簡單說一下.
1. http://cn.cocos2d-x.org/download/ (目前最新版本3.3 375M左右)
2. 下載完成解壓後, 開啟終端, 進入到對應檔案夾。
比如我的:
cd /Users/apple/Desktop/Colin/Cocos2d-x/cocos2d-x-3.3/
再執行
./setup.py
如下:
期間會有幾次詢問,是設定安卓SDK路徑的,不設定安卓直接Enter跳過即可
->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):
之後就OK了,會有提示:
Please execute command: "source /Users/apple/.bash_profile" to make added system variables take effect
照著輸入 source /Users/apple/.bash_profile 就好了
3. 準備建立工程
進入指定檔案夾。比如我的:
cd /Users/apple/Desktop/Colin/Cocos2d-x/cocos2d-x-3.3/tools/cocos2d-console/bin/
如果是緊接著前兩步, 直接輸入 cd tools/cocos2d-console/bin 即可。 (因為當前就在cocos2d-x-3.3目錄下)
接著使用下面命令即可:
cocos new 工程名 -p 包名 -l 語言 -d 目標檔案夾
比如我的:
./cocos new HelloWorld -p com.history.HelloWorld -l cpp -d /Users/apple/Desktop/Colin/Cocos2d-x/WorkSpace
然後就會在對應路徑下建立工程。
之前說過,如果不需要配置 android環境,跳過即可。
如果需要配置,可以參考以下教程:
Mac環境下Cocos2d-x開發環境完全指南
Cocos2d-x 3.x 全平台新手開發配置教程