1. The need for software cocos2d-2.1rc0-x-2.1.3: Official Address: Android SDK: D: \ androidsdkandroid ndk: D: \ androidndk \ android-ndk-r8eCygwin: D: \ cygwin2. configure the VS2010cocos2d-x directory The following install-templates-msvc.bat can be vs installed on the cocos2d-x template, but my machine has installed vs2010 and vs2012 at the same time, run this file after vs2012 has a template, but vs2010 no, at this time you can run D: \ cocos2d-2.1rc0-x-2.1.3 \ template \ msvc \ installwizardforvs2010.js. To run a JS file in windows, run the CMD command to enter the directory of the JS file. Run the following command (run cmd as an administrator): wscript // E: JScript installwizardforvs2010.js so that you can create a cocos2d project in Vs, open D: \ cocos2d-2.1rc0-x-2.1.3 \ cocos2d-win32.vc2010.sln, right-click solution-> rebuild solution, this step is longer, nearly 10 minutes. Right-click solution-> Add-> new project, as shown below:
Select finish to get a new project and run it to get the cocos2d mascot interface: 3. use eclipse to compile both Java and C ++ Code 3.1 to configure the cocos2d-x modify D: \ cocos2d-2.1rc0-x-2.1.3 \ create-android-project.bat and change the corresponding path to the path of the previously decompressed file:
:: modify it to work under your environment set _CYGBIN=D:\cygwin\binif not exist "%_CYGBIN%" echo Couldn't find Cygwin at "%_CYGBIN%" & pause & exit 4:: modify it to work under your environmentset _ANDROIDTOOLS=D:\AndroidSDK\toolsif not exist "%_ANDROIDTOOLS%" echo Couldn't find android sdk tools at "%_ANDROIDTOOLS%" & pause & exit 5:: modify it to work under your environmentset _NDKROOT=D:\AndroidNDK\android-ndk-r8eif not exist "%_NDKROOT%" echo Couldn't find ndk at "%_NDKROOT%" & pause & exit 6
3.2 Create new project run create-android-project.bat, get prompt, enter package name, enter: COM. game (customizable), enter the Project name: xjtugame (customizable), and then List Installed Android platforms. For example, select 1 and android2.3.3 in the current project, then get a lot of output: At this point, get the project xjtugame in D: \ cocos2d-2.1rc0-x-2.1.3. 3.3 Right-click the import project and choose eclipse package explorer> Import> existing Android code into workspace> next> browse> xjtugame \ proj. android-> finish. view Properties after export found that this project depends on libcocos2dx, this project is located in D: \ cocos2d-2.1rc0-x-2.1.3 \ cocos2dx \ platform \ Android \ Java, imported in the same way. The build project is normal, but an error occurs after running. You can also perform the following operations: select the xjtugame project on the left side of Eclipse, right-click New-> Other-> select convert to a C/C ++ Project (adds C/C ++ nature) under C/C ++ ), in the displayed dialog box, select finish. In the displayed dialog box, check whether to switch to C \ c ++ and select No. If C \ c ++ is not installed in this step, you need to install CDT and ndk. For details, refer to http://tools.android.com/recent/usingthendkpluginto open the project definition dialog box, remove the check box of use default build command, and enter in build ):
Bash $ {workspace_loc:/xjtugame}/build_native.sh ndk_debug = 1 V = 1
Then select apply-> OK. Run the project. The error message is displayed.
**** Build of configuration Default for project xjtuGame ****bash D:\cocos2d-2.1rc0-x-2.1.3\xjtuGame\proj.android/build_native.sh NDK_DEBUG=1 V=1 all cygwin warning: MS-DOS style path detected: D:\cocos2d-2.1rc0-x-2.1.3\xjtuGame\proj.android Preferred POSIX equivalent is: /cygdrive/d/cocos2d-2.1rc0-x-2.1.3/xjtuGame/proj.androidplease define NDK_ROOT CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths:http://cygwin.com/cygwin-ug-net/using.html#using-pathnames**** Build Finished ****
In this case, you need to add environment variables. Right-click the project to open the project properties page and add environment variables, for example:
Open JNI-> hellpcpp-> main. CPP found a bunch of errors. This is because eclipse cannot find the corresponding header file. You need to add the relevant files to the project, right-click Project-> New-> folder-> select project and open advance, Click Browse, and select proj. click Finish to import the classes under the same directory of Android. Import the D: \ cocos2d-2.1rc0-x-2.1.3 \ cocos2dx add reference in the same way and use filesystem to locate the following two folders: D: \ androidndk \ android-ndk-r8e \ platforms \ Android-9 \ arch-Arm \ USR \ supported ded: \ cocos2d-2.1rc0-x-2.1.3 \ cocosdenshion \ include
After confirmation, the system prompts whether rebuild include search path is required. Select Yes. After all the projects are rebuilt, all the errors are lost. Run on the real machine to get the cocos2d Hello project. Mac OS below the configuration is similar, Software Download Mac corresponding version can be, specific can refer to: http://blog.csdn.net/wong_judy/article/details/8093760