macOS High Sierra
バージョン 10.13.2
###注意事項
今回はデスクトップ上にcocosというファイル内で
インストールすることを想定してパスを書きますので、その部分は各自のディレクトリ構成に置き換えてください
”ユーザー名”と書かれている部分は各自のユーザー名になります
/Users/"ユーザー名"/Desktop/cocos
##準備
cocos2d-xの公式ページから最新のものをダウンロードする
http://www.cocos2d-x.org/download
Java Development Kitのインストール
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
ダウンロードが完了したら手順に従ってインストールを行う
Android NDKのインストール
https://developer.android.com/ndk/downloads/index.html
クリックしたら利用規約に同意してダウンロードを行ってください
ダウンロードが終わったらandroid-ndk-r14bというファイルになります
Android SDKのインストール
https://developer.android.com/studio/index.html
ページの一番下までスクロールするとあります。
こちらもクリックしたら利用規約に同意してダウンロードを行ってください
ダウンロードが終わったらtoolsというファイルになります。
Apache Antのインストール
http://ant.apache.org/bindownload.cgi
ダウンロードが終わったらapache-ant-1.10.1というファイルになります
##セットアップ
このコマンドをターミナルで実行します
./setup.py
するとNDK_ROOTのパスが聞かれるのでここでパスを入力してパスを通します。
成功すると以下のようなメッセージが出ます
->Please enter the path of NDK_ROOT (or press Enter to skip):/Users/"ユーザー名"/Desktop/cocos/android-ndk-r14b
-> Add NDK_ROOT environment variable...
->Added NDK_ROOT=/Users/"ユーザー名"/Desktop/cocos/android-ndk-r14b
ANDROID_SDK_ROOT
パスにtoolsと入らないので注意が必要です
->Please enter the path of ANDROID_SDK_ROOT (or press Enter to skip):/Users/"ユーザー名"/Desktop/cocos
-> Add ANDROID_SDK_ROOT environment variable...
->Added ANDROID_SDK_ROOT=/Users/"ユーザー名"/Desktop/cocos
ANT_ROOT
ファイルの後に/binを忘れないようにすること
->Please enter the path of ANT_ROOT (or press Enter to skip):/Users/"ユーザー名"/Desktop/cocos/apache-ant-1.10.1/bin
-> Add ANT_ROOT environment variable...
->Added ANT_ROOT=/Users/"ユーザー名"/Desktop/cocos/apache-ant-1.10.1/bin
全てのパスが通し終わると以下のメッセージが出ます
Please execute command: "source /Users/"ユーザー名"/.bash_profile" to make added system variables take effect
そして以下のコマンドを入力、または一度ターミナルを閉じて再度開いたら完了。。のはず
source ~/.bash_profile
cocosとターミナルに入力してこうなったらまだパスが通っていない
cocos
-bash: cocos: command not found
cocosとターミナルに入力して以下のメッセージが出れば環境構築完了です。お疲れ様でした
cocos
Python 2.7.10
/Users/"ユーザー名"/Desktop/cocos/cocos2d-x-3.16/tools/cocos2d-console/bin/cocos.py 2.3 - cocos console: A command line tool for Cocos2d-x.
Available commands:
run Compiles, deploy and run project on the target.
gen-libs Generate prebuilt libs of engine. The libs will be placed in 'prebuilt' folder of the engine root path.
luacompile Encrypt and/or compile lua files.
deploy Compile and deploy a project to a device/simulator.
package Manage package for cocos.
compile Compile projects to binary.
gen-simulator Generate Cocos Simulator.
new Creates a new project.
jscompile Compile and/or compress js files.
Available arguments:
-h, --help Show this help information.
-v, --version Show the version of this command tool.
--ol ['en', 'zh', 'zh_tr'] Specify the language of output messages.
--agreement ['y', 'n'] Skip the agreement with specified value.
Example:
cocos new --help
cocos run --help