23
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

cocos2d-x v3セットアップ

Last updated at Posted at 2014-05-28

当方Mac OS X 10.9.3でxcodeインストール済みです。
android環境がなかったので構築してからcocos2d-x環境を作ります。

android環境構築

android sdk install

$ brew install android
==> Downloading http://dl.google.com/android/android-sdk_r22.6.2-macosx.zip
######################################################################## 100.0%
==> Downloading https://raw.githubusercontent.com/CyanogenMod/android_sdk/938c8d
######################################################################## 100.0%
==> Caveats
Now run the 'android' tool to install the actual SDK stuff.

The Android-SDK location for IDEs such as Eclipse, IntelliJ etc is:
  /usr/local/Cellar/android-sdk/22.6.2

You will have to install the platform-tools and docs EVERY time this formula
updates. If you want to try and fix this then see the comment in this formula.

You may need to add the following to your .bashrc:
  export ANDROID_HOME=/usr/local/opt/android-sdk

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
?  /usr/local/Cellar/android-sdk/22.6.2: 688 files, 94M, built in 25 seconds

$ echo "export ANDROID_HOME=/usr/local/opt/android-sdk" >> ~/.bashrc

android ndk install

$ brew install android-ndk
==> Downloading http://dl.google.com/android/ndk/android-ndk-r9d-darwin-x86.tar.bz2
######################################################################## 100.0%
==> Caveats
We agreed to the Android NDK License Agreement for you by downloading the NDK.
If this is unacceptable you should uninstall.

License information at:
http://developer.android.com/sdk/terms.html

Software and System requirements at:
http://developer.android.com/sdk/ndk/index.html#requirements

For more documentation on Android NDK, please check:
  /usr/local/Cellar/android-ndk/r9d/docs
==> Summary
?  /usr/local/Cellar/android-ndk/r9d: 43731 files, 1.4G, built in 2.6 minutes

ant install

makeのjava版みたいなもの。Apache_Ant
cocos2d-xでandroidビルドするときに使われる。

$ brew install ant
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/ant-1.9.4.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ant-1.9.4.mavericks.bottle.tar.gz
?  /usr/local/Cellar/ant/1.9.4: 1597 files, 39M

cocos2d-x-3.0

cocos2d-x-3.0のインストール

githubのREADME.mdを参考にして作業します。https://github.com/cocos2d/cocos2d-x

http://www.cocos2d-x.org/download
からホームディレクトリにcocos2d-xフォルダを作成してcocos2d-x-3.0.zipをダウンロードして解凍する。

$ cd ~/cocos2d-x/cocos2d-x-3.0/
$ echo "export NDK_ROOT=/usr/local/Cellar/android-ndk/r9d" >> ~/.bashrc
$ echo "export ANDROID_SDK_ROOT=/usr/local/opt/android-sdk" >> ~/.bashrc
$ echo "export ANT_ROOT=/usr/local/bin" >> ~/.bashrc
$ source ~/.bashrc
$ ./setup.py
Setting up cocos2d-x...
->Check environment variable COCOS_CONSOLE_ROOT
  ->Find environment variable COCOS_CONSOLE_ROOT...
    ->COCOS_CONSOLE_ROOT is found : /Users/daichi/cocos2d-x/cocos2d-x-3.0/tools/cocos2d-console/bin

->Configuration for Android platform only, you can also skip and manually edit "/Users/daichi/.bash_profile"

->Check environment variable NDK_ROOT
  ->Find environment variable NDK_ROOT...
    ->NDK_ROOT is found : /usr/local/Cellar/android-ndk/r9d

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

->Check environment variable ANT_ROOT
  ->Find environment variable ANT_ROOT...
    ->ANT_ROOT is found : /usr/local/bin


Please execute command: "source /Users/daichi/.bash_profile" to make added system variables take effect

$ source /Users/daichi/.bash_profile

PROJECTの作成

cocos new MyGame -p com.your_company.mygame -l cpp -d NEW_PROJECTS_DIR

MyGameがアプリ名。
-d NEW_PROJECTS_DIR がプロジェクトが作成されるディレクトリ。

で作成する。

$ cocos new MyGame -p com.your_company.mygame -l cpp -d .
Runing command: new
> Copy template into /Users/daichi/Documents/0_project/cocos2d-x/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.your_company.mygame'

buildする。

$ cd MyGame

iOS
$ cocos run -p ios
android

シミュレータを起動している常態かandroid端末をさした状態で実行する。

$ cocos run -p android -j 4
23
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?