Cocos2d-x 3.0 win7+vs2012 Android Platform construction

Source: Internet
Author: User

*************************************** Reprint Please specify the Source:Http://blog.csdn.net/lttree ******************************************



Off Topic:

Summer vacation, regain cocos2d-x, a year without contact, update to 3.0, build an Android environment does not need to Cygwin. Simple is a lot of ah, is the new time a little trouble =.

Body:

First, pre-preparation work:

Prepare several software:

1.JDK Address: http://www.oracle.com/technetwork/java/javase/downloads/index.html

2.ADT Google provides developers with ADT, directly including the SDK and Eclipse, very good, I am the download of this.

Address: http://developer.android.com/sdk/index.html

3.NDK Address: http://developer.android.com/tools/sdk/ndk/index.html

4.ANT Address: http://ant.apache.org/bindownload.cgi

5.Python do not use the latest version, with 2.7.3 or 2.7.6 also line. Address: https://www.python.org/ftp/python/

6.cocos2d-x 3.0 I was downloading the 3.0 version Http://www.cocos2d-x.org/download

Second, collocation environment variables

Unzip the downloaded Jdk,adt,ndk,ant,python to configure the environment variables.

1.JDK, assuming the JDK exists C:\Program files\java\jdk1.8.0_05, of course storage location by your mood.

Enter environment variable settings:

My Computer--right---Properties----Advanced system settings, (left row)

Advanced (tab, general default) environment variables

Enter settings for the environment variable.

In the following row, the system variable is set:

Create a new variable:java_home inside storage ; C:\Program files\java\jdk1.8.0_05; (Note semicolon)

Find CLASSPATH variable, add inside ;%java_home%\lib;

Find Path variable, add ;%java_home%\bin;

(PS: Here to explain,

①%java_home% is a reference to the address stored by Java_home, and of course you can add it directly in Classpath:

; C:\Program files\java\jdk1.8.0_05\lib; to replace;%java_home%\lib;

To do so, is convenient, if the future changes in the Java location, only need to change the value inside the java_home, no need to move other places.

② each variable before and after the semicolon (;) is very necessary, is to prevent the front and back address is not separated, two addresses only with a semicolon is enough.

③path The original address does not move, if mistakenly deleted, or mistakenly operation, can be copied from other computers.

)

To detect if the JDK environment variable is configured successfully, open the command line and enter: java-version

If it appears:

Of course, the version number can be different (*^__^*)

2. ADT only needs to be decompressed, then the SDK can be installed accordingly.

Ndk,python to store its own root directory in path

Ant saves its own bin directory to path, which is the root of the ant \ Bin

3. Unzip the Cocos2d-x

Enter the folder you extracted from the command line, then run the step.py program inside

You will then be prompted to enter the root directory of the ndt,sdk,ant and enter it as required.

After all is done, close the command line, enter again, enter:

Set Ndk_root

Set Ant_root

Set Android_sdk_root

Set Cocos_console_root

To see if the output is a root directory

III. create the project and transplant it to Android

1. Create a project

We can look at the Help document, open the command line, enter Cocos new--help

Will get:

The writing is quite clear:

Create a new project
Necessary Parameters:PROJECT_NAME project name
Optional Parameters:-H,--help display Help information-P package_name,--package package_nameSet the package name, such as Com.colin.mbgame-L {cpp,lua,js},--language {cpp,lua,js}The primary language that can be used is: [CPP | lua | js]-D directory,--directory directorydirectory where the project is located-T Template_name,--template template_namename of the project template to create
LUA/JS Engineering Parameters:--no-native no native support.At the command line, enter:Cocos New Mygame-p com.vince.mgame-l cpp-d f:/work_room/cocos2d-xGet: Explain the project, build success, go to the corresponding directory can be seen.

2. Transplant Android Platform:

Command line, enter Cocos compile--help

Get:

The explanation is:

compile the current project into binary
Optional Parameters:-h                                                       --help                                                Display Help information - s Src_dir,--src Src_dir,the engineering root directory, such as the above should be f:/work_room/cocos2d-x,if not set, the current directory (the directory to which CMD is located)- q--quiet Less output-P PLATFORM,--platform PLATFORMSelect a platform android|ios|mac|web|win32|linux- m mode,--mode mode debug|release, default to Debug.-j jobs,--jobs jobs Half-line compilation, if you have 4 cores, can be set to 4.
Android Options:--AP read English should be specified SDK version, but not tested, do not understand.Web Options:--source-map Enable Source-map

We go through the command line to the project root we created,

Then enter Cocos compile-p android-j 4

Start compiling, if you end up getting:

BUILD Successful
Total Time:7 seconds
Move apk to F:\work_room\cocos2d-x\mygame\bin\debug\android
Build succeeded.

Description, compile successfully, we can go to the above directory to find the APK, installed on the phone to run it!

Think of the 2.3,2.4 time before the Android apk generation, simply tangled not, now almost a button to get it done.



*************************************** Reprint Please specify the Source:Http://blog.csdn.net/lttree ******************************************


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.