1. download the latest installation package for cocos2d-x
Cd in the terminal to the local directory to be stored, execute the GIT command
Git clone https://Github.com/cocos2d/cocos2d-x.git
2. If IOSProgram, You need to configure the xcode Template
Next, CD to the cocos2d-x directory, execute the sh script inside, install the cocos2d-x Template
Sudo./Install-Templates-xcode.Sh-F
Enter the administrator password.
Then you can see the newly added template in xcode.
3. for Android Development
1. Build a development environment for Android, including eclipse, Android SDK, and ADT (preferably the latest version) to ensure that debugging can be run.
2. Install the C/C ++ plug-in for eclipse
Open eclipse and select help/Install new software
InIn the work with drop-down box, select your eclipse version name, and then selectProgramming versions, open the drop-down list
SelectInstall C/C ++ development tools and restart eclipse
3.
4. configure global environment variables
Execute commands in the terminal
Vim ~ /. Bash_profile
Enter I to edit and add the following Configuration:
Export cocos2dx_root =/users/cocos2dx/cocos2d-Xexport ndk_root=/Users/Android-ndk-R8dexport android_ndk_root=/Users/Android-ndk-R8dexport android_sdk_root=/Users/Android-SDK-Macosxexport path=$ Android_ndk_root: $ pathexport path= $ Android_sdk_root: $ path
Press ESC and run the command again.
: WQ
Save the configuration and replace the corresponding path in the preceding configuration.
Cocos2dx_root corresponds to the local directory of the cocos2d-x
Ndk_root and android_ndk_root correspond to the local ndk directory
Android_sdk_root corresponds to the local directory of Android SDK
5. Create an android test project
CD to cocos2d-x local directory, Execute Command
./Create-Android-project.Sh
Enter the package name and press Enter.
Com. Test. testdemo
Enter the sdk id (for example, 3, corresponding to sdk4.0.3), and press Enter.
Enter the application directory name, such as testdemo, and press Enter.
Now there is a testdemo directory under the cocos2d-x directory
CD to proj. Android under the testdemo directory, and then execute the following command to compile the project
./Build_native.Sh
6. Create AVD
Note: The cocos2d-x version 2.0 requires opengl2.0 support, while opengl2.0InAndroid2.2And then the real machine,Simulator version4.0.3Before Running
Open in eclipseAndroid Virtual Device Manager
To add a new AVD, you must check the use host GPU.
7. Import the testdemo application in eclipse, select the project on the left, right-click Run as =>Run deployments ......
On the left of the displayed dialog box, select testdemo, select the target tag, and select the generated AVD
Scroll down,Enter-GPU on in "Additional emulator command line options"
Click "Apply" to run