装置好,相应的环境之后,咱们便能够开端创立cocos2d-x 的android 工程了
进入cocs2d-x目录,用文本编辑器翻开create-android-project.bat(在windows 7上假如正常双击,或许创立时有些文件的权限缺乏,导致创立工程不成,能够在此文件的榜首行加上cd /d %~dp0,然后右键以管理员身份运转)
找到以下几个界说:

@echo off
:: This script is used to create an android project.
:: You should modify _ANDROIDTOOLS _CYGBIN _NDKROOT to work under your environment.
:: Don’t change it until you know what you do.
cd /d %~dp0
setlocal
:: Check if it was run under cocos2d-x root
if not exist %\create-android-project.bat echo Error!!! You should run it under cocos2dx root pause exit 2
if not exist %~dpn0.sh echo Script %~dpn0.sh not found pause exit 3
:: modify it to work under your environment
set _CYGBIN=D:\cygwin\bin
if not exist %_CYGBIN% echo Couldn’t find Cygwin at %_CYGBIN% pause exit 4
:: modify it to work under your environment
set _ANDROIDTOOLS=E:\android-sdk-windows\tools
if not exist %_ANDROIDTOOLS% echo Couldn’t find android sdk tools at %_ANDROIDTOOLS% pause exit 5
:: modify it to work under your environment
set _NDKROOT=E:\android-ndk-r8-windows\android-ndk-r8
if not exist %_NDKROOT% echo Couldn’t find ndk at %_NDKROOT% pause exit 6
:: create android project
set /P _PACKAGEPATH=Please enter your package path. For example: org.cocos2dx.example:
set /P _PROJECTNAME=Please enter your project name:
if exist %\%_PROJECTNAME% echo %_PROJECTNAME% exists, please use another name pause exit 7
echo Now cocos2d-x suppurts Android 2.1-update1, 2.2, 2.3 3.0
echo Other versions have not tested.
call %_ANDROIDTOOLS%\android.bat list targets
set /P _TARGETID=Please input target id:
set _PROJECTDIR=%\%_PROJECTNAME%
echo Create android project
call %_ANDROIDTOOLS%\android.bat create project -n %_PROJECTNAME% -t %_TARGETID% -k %_PACKAGEPATH% -a %_PROJECTNAME% -p %_PROJECTDIR%
:: Resolve ___.sh to /cygdrive based *nix path and store in %_CYGSCRIPT%
for /f delims= %%A in (‘%_CYGBIN%\cygpath.exe %~dpn0.sh’) do set _CYGSCRIPT=%%A
:: Resolve current dir to cygwin path
for /f delims= %%A in (‘%_CYGBIN%\cygpath.exe %’) do set _CURRENTDIR=%%A
:: Resolve ndk dir to cygwin path
for /f delims= %%A in (‘%_CYGBIN%\cygpath.exe %_NDKROOT%’) do set _NDKROOT=%%A
:: Throw away temporary env vars and invoke script, passing any args that were passed to us
endlocal %_CYGBIN%\bash –login %_CYGSCRIPT% %_CURRENTDIR% %_PROJECTNAME% %_NDKROOT% %_PACKAGEPATH% windows
pause

将_CYGBIN=设置为cycgwin\bin装置的的绝对路径。
将_ANDROIDTOOLS设置为android sdk 的tools绝对路径
将_NDKROOT设置为android ndk的绝对路径
修正结束,保存后
双击create-android-project.bat开端工程创立导游
首先是输入包名(主张依照android的命名规矩),如com.android.test
然后输入工程称号(留意不要输入已有的文件夹的姓名,假如同名,会被覆盖掉的),如testandroid,如下图:

然后挑选target id,

其会列出机器上装置的一切版别的sdk,咱们挑选6,即2.3.2的sdk.

进入g:\cocos2d-x目录发现多了一个名为testandroid的目录,里边包括三个目录

其间Classes:是寄存默许工程的C++文件
proj.android 是android的eclipse工程项目
Resources 资源文件
下来咱们开端编译刚创立的testandroid项目
翻开cygwin,进入到testandroid/proj.android目录,输入 ./build_native.sh 开端编译如下图: