Cocos2d-x Deployment and Usage Guide
Prerequisites
System Requirements
- macOS: 10.7+ with Xcode 8+
- Linux: Ubuntu 14.04+ with CMake 3.1+
- Windows: 7+ with Visual Studio 2015+
- Python: 2.7.5+ (NOT Python 3)
- Java: JRE or JDK 1.6+ for web publishing
Platform-Specific Requirements
- Android: NDK r16+ and Android Studio 3.0.0+
- iOS: iOS 8.0+ for iPhone/iPad games
- macOS: OS X v10.9+ for Mac games
- Windows: Windows 7+ for Win games
Installation
Clone the Repository
$ git clone https://github.com/cocos2d/cocos2d-x.git
$ cd cocos2d-x
Install Dependencies
$ python download-deps.py
$ git submodule update --init
Environment Setup
$ ./setup.py
$ source FILE_TO_SAVE_SYSTEM_VARIABLE
Linux Dependencies (if using Linux)
$ ./install-linux-deps.sh
Configuration
Environment Variables
The setup.py script will automatically configure necessary environment variables. You need to source the generated file:
$ source FILE_TO_SAVE_SYSTEM_VARIABLE
IDE Configuration
- Non-Android platforms: Use CMake to generate project files
- Android: Import existing project from
PROJECT_DIR/proj.androidin Android Studio
Build & Run
Running Tests
$ cd cocos2d-x
$ mkdir build
$ cd build
$ cocos run --proj-dir .. -p [mac|win32|android|linux|ios]
Starting a New Game Project
$ cd cocos2d-x
$ ./setup.py
$ source FILE_TO_SAVE_SYSTEM_VARIABLE
$ cocos new MyGame -p com.your_company.mygame -l cpp -d NEW_PROJECTS_DIR
$ cd NEW_PROJECTS_DIR/MyGame
$ mkdir build
$ cd build
$ cocos run --proj-dir .. -p [mac|win32|android|linux|ios]
Language Options
- Use
-l cppfor C++ projects (default) - Use
-l luafor Lua projects
Deployment
Platform-Specific Deployment
iOS
- Build with Xcode
- Deploy to App Store Connect
Android
- Build with Android Studio
- Deploy to Google Play Console
macOS
- Build with Xcode
- Distribute via Mac App Store or direct download
Windows
- Build with Visual Studio
- Distribute via Microsoft Store or direct download
Linux
- Build with CMake
- Distribute via package managers or direct download
Web Publishing
- Requires JRE or JDK 1.6+
- Use Cocos2d-x web publishing tools
Troubleshooting
Common Issues
Python Version Error
- Ensure you're using Python 2.7.5+, not Python 3
- Check with:
python --version
Submodule Update Fails
- Run:
git submodule update --init --recursive
Build Configuration Issues
- Verify environment variables are properly sourced
- Check CMake version compatibility
Android Build Issues
- Ensure NDK r16+ is installed
- Verify Android Studio version is 3.0.0+
Missing Dependencies
- Re-run:
python download-deps.py - Check internet connection during dependency download