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

来源:未知 责任编辑:智问网络 发表时间:2013-10-22 19:17 点击:

我的环境是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.2cto.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上低很多啊。

 

 

 

    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • cocos2d-x学习笔记(19)--label 、label atlas
    • cocos2d-x学习笔记(23)--地图的使用3--CCTMXLayer
    • Cocos2d-x学习(一):HelloWorld
    • cocos2dx在xcode下开发,编译到android上(2)
    • cocos2d 设置屏幕默认方向
    • cocos2d-x学习笔记(22)--地图的使用2(TMX) --Z-Order、AnchorPoi
    • Cocos2d-x 2.0 之 Actions “三板斧” 之一
    • cocos2d-x学习笔记(18)--游戏打包(windows平台)
    • cocos2d-x学习笔记(16)--spritesheet(精灵表单)
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1