当前位置:编程学习 > wap >>

[Cocos2d-x游戏引擎开发笔记]在ubuntu上将游戏发布到Android

我的环境是ubuntu 12.04 ,android-ndk-r8,Cocos2d-2.0-x-2.0.4,eclipse 3.7.2


我之前就搭建好了NDK的开发环境,NDK环境搭建请看Android NDK开发配置NDK。

1.配置NDK和SDK
进入Cocos2d-2.0-x-2.0.4,用gedit打开create-android-project.sh,做出如下改动


[cpp] view plaincopyprint?NDK_ROOT_LOCAL="/home/zhycheng/android-ndk-r8" 
ANDROID_SDK_ROOT_LOCAL="/home/zhycheng/android-sdk-linux" 

NDK_ROOT_LOCAL="/home/zhycheng/android-ndk-r8"
ANDROID_SDK_ROOT_LOCAL="/home/zhycheng/android-sdk-linux"指定NDK和SDK的目录。

然后执行该文件,生成andriod项目。

2.编译
打开.bashrc文件,在最后加入

export NDK_ROOT=/home/zhycheng/android-ndk-r8

进入android工程项目,执行build_native.sh.

[cpp]
zhycheng@zhycheng-Lenovo-B460:~/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android$ ./build_native.sh 

zhycheng@zhycheng-Lenovo-B460:~/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android$ ./build_native.sh

最后会出现如下结果


[cpp] view plaincopyprint?NDK_ROOT = /home/zhycheng/android-ndk-r8 
COCOS2DX_ROOT = /home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android/../.. 
APP_ROOT = /home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android/.. 
APP_ANDROID_ROOT = /home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android 
Using prebuilt externals 
make: Entering directory `/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android' 
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver 
Gdbsetup       : libs/armeabi/gdb.setup 
Install        : libgame.so => libs/armeabi/libgame.so 
make: Leaving directory `/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android'  www.zzzyk.com
zhycheng@zhycheng-Lenovo-B460:~/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android$  

NDK_ROOT = /home/zhycheng/android-ndk-r8
COCOS2DX_ROOT = /home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android/../..
APP_ROOT = /home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android/..
APP_ANDROID_ROOT = /home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android
Using prebuilt externals
make: Entering directory `/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android'
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Install        : libgame.so => libs/armeabi/libgame.so
make: Leaving directory `/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android'
zhycheng@zhycheng-Lenovo-B460:~/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj.android$

 

我以前编译过,这个编译需要一定的时间,最后在libs/armeabi文件夹下生成libgame.so。


3.运行
将该工程导入eclipse中,将Coco2d-2.0-x-2.0.4目录下的cocos2dx/platform/android/java/src下的org文件夹复制到android工程src目录下,开始运行。注意,一定要用真机测试,我在模拟器上测试出错。

最后贴出一张图片吧

 \


只有48帧,比在pc上低很多啊。

 

 

 

补充:移动开发 , 其他 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,