COCOS2DX 3.0 Development Environment Building--eclipse built in Android engineering

Source: Internet
Author: User

First, preface:

This section describes some of the basics of Cocos2d-x 3.0, and compiles our cocos2d-x project on Eclipse to successfully execute HelloWorld. After reading this blog post. You'll know that Cocos2d-x 3.0 has changed so much. has become so simple, the environment construction, the project creation, compiles the way to be more humanized.

Second, the Environment preparation:

1. Download the ADT Bundle (Eclipse Bundle SDK and ADT). Or, install Eclipse's ADT plugin.


2. Install JDK, NDK, Ant, Python. Then configure the environment.

3,cocos2d-x 3.0 download, environment configuration.

Now step-by-step to configure the environment

1)Eclipse Preparation, this is primarily a development tool. Just now the official Android recommendation. An integrated SDK and ADT Eclipse, very useful. Here is mainly in the network download is good, as to whether to visit the network can access to download on your FQ.

Http://developer.android.com/sdk/index.html

2) Android compilation environment need to use ANDORID_SDK android_ndk, Ant, JDK, in addition to the JDK need to install, the other is the green version of the direct decompression can be.

We extracted the SDK, NDK, and ant into the same directory and changed the SDK directory named Adt,ndk NDK. Ant is ant for the convenience of later use. I unpacked the files and placed them in the D:\softfile\android directory.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdtaxmta2nzm2ma==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

To configure the JDK:

Manually configure the environment variables after the JDK is installed

1) Create a new java_home variable in the system variable, the value of the variable is: D:\Program files\java\jdk1.6.0_14 (fill in according to their own installation path)

2) New CLASSPATH variable, variable value is:.; %java_home%\lib;%java_home%\lib\tools.jar (Note the previous.) Don't forget it)

3) Add the variable value in the path variable (existing without new):%java_home%\bin;%java_home%\jre\bin (Note the ";" between the variable values) Separated

4) Another logoff system and once again login "Start"-"execute" and input "Javac"-"enter", assuming that the normal print usage instructions to configure the success!


The next step is to configure the other environment, and other environment configurations need to be done with Python and cocos, so now we'll configure the Python and Cocos environments.


Python Installation and Environment configuration:

The Python 2.X version number needs to be downloaded here. Do not download the version number above python3.0, otherwise there will be an error in execution.

Python installs using the default installation method, but we need to configure the environment variables after the installation is complete.

Locate the path variable in the system variable, environment variable, advanced system settings, properties, and so on my computer (right-click). and add an environment variable to its value that points to Python. The format is [python installation path]; For example, I installed in C drive My environment variable is added to D:\Python27;
After the configuration is complete, remember to log off and log on again. System environment variables will not take effect

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdtaxmta2nzm2ma==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">


Next. We want to download the latest version number of Cocos2d-x, so far cocos2d-x has been updated to the 3.3 version number, here I download is the 3.0 version number.

http://www.cocos2d-x.org/download/


NDK, ANT, SDK environment configuration:

After the download is complete, we unzip to disk and open the Cocos2d-x directory to find setup.py this file, execute. Or, for example, the following actions:

1) Open the console cmd. Enter the root folder of the COCOS2DX
2) Enter command: Python setup.py, perform the results for example with what you see (Note the Red box section. Suppose you do not configure environment variables such as NDK. Then you will be asked to enter the Ndk,sdk,ant path here)

Let's say you don't configure the Android environment now, so you just have to go straight on. This time the Python script will help us set the environment variables required for cocos2d-x execution. Logout, Login again





After we have configured these, we can see the corresponding environment configuration in the environment variables, and the Cocos are configured on our own initiative.


After configuring this, we open cmd to execute the Cocos command to check whether the entire development environment is successful, assuming that the settings are not a problem, such as the following interface
Here we can see that the cocos.py script can run 4 commands, and the role of each command has been explained very clearly.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdtaxmta2nzm2ma==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

Iii. Creation of the project

now it's time to use the command to create an empty project:Create project (in parentheses for explanation) in console cmd Type example cocos new Hello (project name)-Pbing.stone. Hello (package name)-L CPP (project type)-D E:\MyCocos\cocos2dx_ Workspace (Project storage path)
Like what. We want to create a CPP project, and then I can type "cocos new Mygame-p bing.stone.mygame-l cpp-d f:cocos//myproject.

This command will help us create an empty project called Mygame in F:/cocos/myproject, for example, as seen in the following:



Perform this command such as the following:



When you create a project, you can see the items in the directory:


Iv. Eclipse to build Android projects

When we use Eclipse to build Android. It is recommended to follow the steps below:
Go to the COCOS2DX project you created. Enter the Proj.android folder, for example, under f:cocos//myproject/create a project called Mygame, go to the Mygame/proj.android folder, run the following command:
Python build_native.py

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdtaxmta2nzm2ma==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

The above steps are considered to be compiled. When the compilation is complete. We will be able to import the Proj.android project into our eclipse.
Then use Eclipse to open an existing Android project,



After you import the project, there must be an error.   Now that our Cocos package has not been imported, that is, libcocos2dx, is now a key step, we need to download the Cocos inside the Android package to import it, that is the package it? Cocos\cocos2d-x-3.0\cocos\2d\platform\android\java


Of course, not a simple import, we need to copy the Java directory to our project below. The MyProject we created.

Java projects, such as MyProject, are copied from COCOCS2DX. Put it in a folder with the project that we created with the Cocos command, and then import it with Eclipse.



after importing LIBCOCOS2DX, it is the configuration path:


You can then right-click->run as to execute the Android project directly. No additional configuration is necessary (Cocos2d-x 3.0 is this simple).



The above is how to execute our cocos2d-x project in Eclipse.

Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

COCOS2DX 3.0 Development Environment Building--eclipse built in Android engineering

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.