ruk·si

🥥 Installing Cocos2D-x

Updated at 2015-03-11 02:57

Windows

  1. Install for Windows and Android builds:
    1. Python 2.7., check with python --version.
    2. JDK 1.7, check with java -version.
    3. Visual Studio 2012
    4. Microsoft .NET Framework 4 Client Profile,
    5. Microsoft Access Database Engine 2010 Redistributable,
    6. Android SDK,
    7. Android NDK,
    8. Apache Ant
  2. Download and unzip Cocos2d-x 3.4 somewhere.
    # Configure environmental variables.
    cd /path/to/cocos2d-x
    python setup.py
    
    Remember that you need to restart command-line tool each time you
    change environmental variables. Changing Java env variables also might
    require full reboot.
    
  3. Create a project.
    # Create a multi-platform project.
    # Open command-line at the directory you want to contain "MyGame" directory.
    cocos new MyGame -p com.MyCompany.MyGame -l cpp
    
    # Run it
    cd /path/to/MyGame
    cocos run -p win32
    # or add source path with `-s /path/to/projects/MyCompany/MyGame`
    # All available platforms: android, ios, win32, mac, linux
    

Mac

  1. Install:
    1. XCode through AppStore for editing and iOS/Mac building.
    2. Android NDK, Android SDK, Apache Ant and Java for Android development for Android building.
  2. Download and unzip Cocos2d-x 3.4 somewhere.
    # Add following to ~/.bash_profile, ~/.bash_login or ~/.profile
    export NDK_ROOT=/path/to/android-ndk
    export ANDROID_SDK_ROOT=/path/to/android-sdk
    export ANT_HOME=/path/to/ant
    export ANT_OPTS=-Xmx256M
    export ANT_ROOT=$ANT_HOME/bin
    export COCOS_X_ROOT=/path/to/cocos2d-x-3.4
    export COCOS_TEMPLATES_ROOT=/path/to/cocos2d-x-3.4/templates
    export COCOS_CONSOLE_ROOT=/path/to/cocos2d-x-3.4/tools/cocos2d-console
    export PATH=$COCOS_CONSOLE_ROOT:$ANT_ROOT:$PATH
    
  3. Create project.
    # Create a multi-platform project.
    # Open command-line at the directory you want to contain "MyGame" directory
    cd /path/to/projects
    cocos new MyGame -p com.MyCompany.MyGame -l cpp -d ~/MyCompany
    
    # Run it
    cd MyGame
    cocos run -p mac
    # or add source path with `-s /path/to/projects/MyCompany/MyGame`
    # All available platforms: android, ios, win32, mac, linux
    # You can also run on Mac using XCode play.