cocos2dx

ubuntu12.04+jdk1.6

1.install eclipse

2.linux GNU GCC

3.eclipse CDT plugins

4.andrid sdk

5.android ndk
下载android-ndk-r8d,并解压至/opt/NDK/下
sudo vim /etc/profile:export NDK_ROOT=/opt/android-sdk-linux/NDK/android-ndk-r8d
source /etc/profile
cd $NDK_ROOT/samples/hello-jni -> ndk-build

6.cocos2d
sudo vim /opt/cocos2d-x-2.1.4/create-android-project.sh:
NDK_ROOT_LOCAL="/opt/NDK/android-ndk-r8d"#NDK目录
ANDROID_SDK_ROOT_LOCAL="/opt/android-sdk-linux"#SDK目录
创建cocos2d项目:
运行/opt/cocos2d-x-2.1.4/create-android-project.sh
输入package path、target id、project name
运行新建项目下的proj.android/build_native.sh

将复制/opt/cocos2d-x-2.1.4/cocos2dx/platform/android/java/src/org/cocos2dx/lib文件夹到android工程下src/org/cocos2dx(或右击工程Properties -> C/C++ Build -> settings -> GCC C++ Linker -> Libraries -> add -> cocos2d-x-lib有待验证或右击工程Properties->Android->project build target->android4.0->Library->Reference->/opt/cocos2d-x-2.1.4/cocos2dx/platform/android/java并选中Is Library)
解决模拟器下不能运行问题:
Cocos2dxActivity中mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer())前添加:
this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
AndroidManifest.xml中加入:<uses-feature android:glEsVersion="0x00020000" android:required="true" />
AVD配置时勾选Use Host GPU

eclipse -> New C/C++ Project
右键点击新工程,选择Properties -> C/C++ General -> Paths And Symbols -> includes:
选中Languages中任一项添加:
Directory:/opt/cocos2d-x-2.1.4/cocos2dx,并勾上add to all configurations和add to all languages
Directory:/opt/cocos2d-x-2.1.4/cocos2dx/include(同上)
Directory:/opt/cocos2d-x-2.1.4/cocos2dx/platform/android(同上)
Directory:/opt/cocos2d-x-2.1.4/CocosDenshion/include(同上)
Directory:/opt/NDK/android-ndk-r8d/platforms/android-14/arch-arm/usr/include(同上)

新建android project->File -> New -> Android -> Android Project from Existing Code -> Root Directory:/home/works/cocos2dExample/proj.android(此工程是上面创建的)
右击工程Properties -> Builders -> NEW -> Program:
Name:JNI_Build
Main Location -> Browse File System:/opt/NDK/android-ndk-r8d/ndk-build
Main Working Directory -> Browse Workspace:上面创建的工程
Refresh 选中Refresh resources upon completion.
Environment -> New:
Name:NDK_MODULE_PATH
Value:/opt/cocos2d-x-2.1.4;/opt/cocos2d-x-2.1.4/cocos2dx/platform/third_party/android/prebuilt
Build Option勾选During auto builds和Specify working set of relevant resources
Specify Resources -> 勾选已创建工程的jni

7.Cocos2d-x在Eclipse自动补全

参考:
Ubuntu下cocos2d-x开发环境搭建及配置
cocos2d-x学习笔记 Eclipse+cdt实现cocos2dx跨平台解决方案

posted @ 2013-07-13 13:08  WenEric  阅读(472)  评论(0编辑  收藏  举报