cocos2dx如何打包apk接下来我们就要开始学习将项目打包成apk





1)将proj.win32里面的.h以及.cpp文件拷贝到Classes中(如果以后修改那些.cpp文件或.h文件需要继续从proj.win32拷贝到Classes中覆盖掉之前的文件再生成新的android工程)
2)进入proj.android,用UE编辑器修改build_native.sh文件
在第三行下面加入,如下
NDK_ROOT=/cygdrive/e/android/android-ndk-r9c
COCOS2DX_ROOT=/cygdrive/e/cocos2d-x-2.2.1
GAME_ROOT=$COCOS2DX_ROOT/projects/gametest04
GAME_ANDROID_ROOT=$GAME_ROOT/proj.android
RESOURCE_ROOT=$GAME_ROOT/Resources
在第三行下面加入,如下
NDK_ROOT=/cygdrive/e/android/android-ndk-r9c
COCOS2DX_ROOT=/cygdrive/e/cocos2d-x-2.2.1
GAME_ROOT=$COCOS2DX_ROOT/projects/gametest04
GAME_ANDROID_ROOT=$GAME_ROOT/proj.android
RESOURCE_ROOT=$GAME_ROOT/Resources

3)进去proj.android\jni下面修改Android.mk,
将所有.cpp的路径都添加进去即可,如本人增加了下面那些路径
将所有.cpp的路径都添加进去即可,如本人增加了下面那些路径

好了 修改完这些保证没错误之后
打开cygwin,然后进入目录gametest04/proj.android/
打开cygwin,然后进入目录gametest04/proj.android/
执行./build_native.sh
到最后./build_native.sh之后没错误的话(这个过程比较久大概十几二十分钟,有些可能要半个钟头),它就会生产android项目了(成功的判断是看他是否生产.so文件)
成功的话在路径cocos2d-x-2.2.1\projects\gametest04\proj.android\libs\armeabi下能看到libcocos2dcpp.so文件

成功的话在路径cocos2d-x-2.2.1\projects\gametest04\proj.android\libs\armeabi下能看到libcocos2dcpp.so文件



然后接下来就可以生成可以在eclipse上运行的android工程了,导入cocos2d-x-2.2.1\projects\gametest04\proj.android这个就可以在eclipse上看到该工程了

项目加载进来后会提示缺少cocos2dx包,我们去cocos2d-x-2.2.1/cocos2dx/pathform/android/java/scr/
把org文件拷到我们项目gametest04/proj.android/src/下


接着刷新下我们的项目,好了没问题了,可以编译
成功运行后会在bin/生成一个apk文件
如果需
要把项目在真机上弄成竖屏,只需在AndroidManifest.xml中改一改,
android:screenOrientation="landscape"(横
屏),android:screenOrientation="portrait"(竖屏),它默认为横屏
好了,打包apk圆满完成
接下来就是学习开发cocos2dx的时候了
推荐几个软件:
cocostudio_Full_V1.2.0.0
TexturePacker
Visual Assist X