mac下配置cocos2d-x3.0

今天看到3.0的正式版發佈了,就當即蕩下來試試3.0,下面記錄下環境變量配置過程java

打開用戶目錄下.bash_profile文件,配置環境linux

一、首先配置下android sdk,個人是在opt目錄下android

#sdk
export ANDROID_SDK_ROOT=/opt/android-sdk-macosx
export PATH=$PATH:$ANDROID_SDK_ROOT
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools

二、ndkmacos

#ndk
export NDK_ROOT=/opt/android-ndk-r9b
export PATH=$PATH:$NDK_ROOT

三、ant apache

#ant
export ANT_ROOT=/opt/apache-ant-1.9.3/bin
export PATH=$PATH:$ANT_ROOT

等一切都配置好以後,咱們如今就應該到終端下cocos2d-x3.0的目錄下執行如下命令:
bash

./setup.py

執行過以後終端會顯示如下內容ui

???mcbookpro:cocos2d-x-3.0$ ./setup.py 

Setting up cocos2d-x...
->Check environment variable COCOS_CONSOLE_ROOT
  ->Find environment variable COCOS_CONSOLE_ROOT...
    ->COCOS_CONSOLE_ROOT is found : /Project/cocos2d-x-3.0/tools/cocos2d-console/bin

->Configuration for Android platform only, you can also skip and manually edit "/Users/你的用戶名/.bash_profile"

->Check environment variable NDK_ROOT
  ->Find environment variable NDK_ROOT...
    ->NDK_ROOT is found : /opt/android-ndk-r9b

->Check environment variable ANDROID_SDK_ROOT
  ->Find environment variable ANDROID_SDK_ROOT...
    ->ANDROID_SDK_ROOT is found : /opt/android-sdk-macosx

->Check environment variable ANT_ROOT
  ->Find environment variable ANT_ROOT...
    ->ANT_ROOT is found : /opt/apache-ant-1.9.3/bin


Please execute command: "source /Users/你的用戶名/.bash_profile" to make added system variables take effect

若是出現以上內容咱們的配置就成功了,你到你的 /Users/你的用戶名/.bash_profile文件中看一下,會默認爲咱們添加如下兩行代碼lua

# Add environment variable COCOS_CONSOLE_ROOT for cocos2d-x
export COCOS_CONSOLE_ROOT=/Project/cocos2d-x-3.0/tools/cocos2d-console/bin
export PATH=$COCOS_CONSOLE_ROOT:$PATH

這時候你再重啓或執行如下代碼:spa

source /Users/你的用戶名/.bash_profile

執行完成後沒有任何提示,不要緊,linux下沒有消息,就是好消息。code

完成以上以後,你在終端下敲以cocos new 命令,你會驚奇的發現

mcbookpro:cocos2d-x-3.0$ cocos new
Runing command: new
usage: cocos new [-h] [-p PACKAGE_NAME] -l {cpp,lua,js} [-d DIRECTORY]
                 [-t TEMPLATE_NAME] [--no-native]
                 [PROJECT_NAME]
cocos new: error: argument -l/--language is required

你能夠敲如下命令建立本身的helloworld工程

 cocos new helloworld -p com.helloworld -l cpp -d /Project/cocos2dx/

//爲第一次搞的小盆友們解釋下這幾個參數:
helloworld//工程名  
-p 後跟你的包名 
-l cpp  這是一個cpp工程
-d 後跟的是你要建的工程路徑

命令執行完以後終端下出現:

mcbookpro:cocos2d-x-3.0$ cocos new helloworld -p com.package -l cpp -d /Project/

Runing command: new
> Copy template into /Project/helloworld
> Copying cocos2d-x files...
> Rename project name from 'HelloCpp' to 'helloworld'
> Replace the project name from 'HelloCpp' to 'helloworld'
> Replace the project package name from 'org.cocos2dx.hellocpp' to 'com.package'

oh my god!咱們的配置到如今就完成了,這是多麼的簡單呀!

那就盡情的享受遊戲開發給咱們帶來的無窮樂趣吧!!!

歡迎轉帖,記得標明出處,謝謝

相關文章
相關標籤/搜索