Create a HelloWorld Project
Unzip the compressed package you just downloaded into the folder you specified.
Go to directory cocos2d-x-3.2alpha0/tools/cocos2d-console/bin/cocos.py
Open terminal Run cocos.py script Create file
./cocos.py new HelloWorldDemo -p com.coco2dx.org -l cpp -d ~/Desktop或者python cocos.py new HelloWorldDemo -p com.coco2dx.org -l cpp -d ~/Desktop
Parameter description:
- Helloworlddemo for Project name
-pAfter the package name
-lfollowed by the development of the language type, there are CPP, LUA, JS three types
-dThe directory after which the project is stored
Run the project
After the project is created, use Xcode to open the Xcode project file in Helloworlddemo/proj.ios_mac and run the project
Mac build cocos2d-x v3.2alpha0 Android development Environment prep work
Download the latest version of the COCOS2D-X official website v3.2alpha0
Download Android SDK to Android official website
Finally, you need to download the Android NDK on the Android website.
Jdk
Detects if the JDK is installed and whether the version is greater than 1.6.0. Open Terminal, enter:
1java -version
MacOS x will download the JDK automatically.
You will see the following information:
java version "1.6.0_37" Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
When you're done checking, you can start setting up your Mac's Android development environment.
Configuring the Android SDK Environment
Unzip the zip file (named "Adt-bundle-<os_platform>.zip") and save it to the appropriate location, such as the "Development" (development) directory of the home directory.
Open the adt-bundle-<os_platform>/eclipse/directory and start Eclipse. That's it! Now that the integrated development environment has loaded the Android Developer (Android Developer tools) tool plug-in, the SDK is ready.
Installing eclipse in the MBP retina pc
If you're using a MacBook Pro pc with a Retina display, note that original eclipse does not support Retina display, but you can use simple techniques to start retina support. (This method is from: https://bugs.eclipse.org/bugs/show_bug.cgi?id=382972)
- Perform "Show Package contents" on Eclipse.app
- Edit the Contents/info.plist file.
- Just above the code below.
</dict></plist>
Add the following code
<key>NSHighResolutionCapable</key><true/>
- Move the Eclipse.app app to a new folder (clear the cache for the Info.plist file in OS X), and then move back to the old folder. 5. Start eclipse, and the retina display is supported.
Open Eclipse, select Adt-> Preferences, and select the Android item to specify the installation directory for the Android SDK. As shown in the following:
Configuring the NDK Environment
The NDK is used to generate the native file when compiling the iOS project source files into a project.
First unzip the downloaded NDK and ADT in the same parent folder.
Add the NDK environment variable as follows:
export NDK_ROOT="/Users/yiming/Desktop/android-ndk-r9"
Restart the terminal.
Create a HelloWorld Project
Unzip the compressed package you just downloaded into the folder you specified.
Go to directory cocos2d-x-3.2alpha0/tools/cocos2d-console/bin/cocos.py
Open terminal Run cocos.py script Create file
./cocos.py new HelloWorldDemo -p com.coco2dx.org -l cpp -d ~/Desktop或者python cocos.py new HelloWorldDemo -p com.coco2dx.org -l cpp -d ~/Desktop
Parameter description:
- Helloworlddemo for Project name
-pAfter the package name
-lfollowed by the development of the language type, there are CPP, LUA, JS three types
-dThe directory after which the project is stored
Build Android Project files
Execute the build_native.py script under helloworlddemo/proj.android to compile
Compile successfully!
and copy the helloworlddemo/cocos2d/cocos/2d/platform/android/java/src/org/cocos2dx/lib folder to the helloworlddemo/ under the PROJ.ANDROID/SRC/ORG/COCOS2DX.
Import Android project to eclipse
Import the generated helloworlddemo into eclipse by importing a method that already exists on an existing Android project as follows:
You may see the following error message:
The import org.cocos2dx.lib cannot be resolved HelloWorld.java /HelloWorld/src/com/young40/test line 26 Java Problem Cocos2dxActivity cannot be resolved to a type HelloWorld.java /HelloWorld/src/com/young40/test line 30 Java Problem Cocos2dxActivity cannot be resolved to a type HelloWorld.java /HelloWorld/src/com/young40/test line 33 Java Problem
You will need to
/opt/cocos2d-2.1beta3-x-2.1.1/cocos2dx/platform/android/java
Follow the above method to import into eclipse. Then right-click Refresh on the Helloworlddemo project and the error disappears.
Set your phone to debug mode and connect it to your computer with a USB cable, run HelloWorld in Eclipse, and see the HelloWorld already running on your phone!
(2) Mac environment construction