Cocos2d-x学习笔记(3:将VS2010下cocos2d-x 2.0.2 win32工程移植到android环境)

前端之家收集整理的这篇文章主要介绍了Cocos2d-x学习笔记(3:将VS2010下cocos2d-x 2.0.2 win32工程移植到android环境)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
因为本人以前使用WiEngine引擎,所以文章跳跃幅度比较大。

问题:在WIN7下使用VS2010使用调试通过一个COCOS2D-X项目后如何移植到ANDROID环境并进而打包安装到真机(或者模拟器)上呢?

STEP 1:@H_403_5@配置android工程生成
@H_403_5@
用edit plus之类的编辑器打开 @H_403_5@cocos2d-x目录下的 @H_403_5@create-android-project.bat,并进行修改


@H_403_5@

@H_403_5@
注意:上述文件中的几个路径一定要与你自己的路径对应起来!另外,这一步配置成功后,以后再创建其他的工程的android版本便基本上不再需要修改了。


@H_403_5@@H_403_5@STEP 2:@H_403_5@创建android工程

@H_403_5@@H_403_5@@H_403_5@这一步是通过运行cocos2d-x目录下的create-android-project.bat实现的(在WINDOWS资源管理器中右键单击此文件,然后选择以管理员身份运行即可)。参考其它的资料,我使用管理员身份运行此文件的(一般运行情况还没有试验)。
@H_403_5@然后,屏幕上提示你输入包名和项目名。
@H_403_5@注意:如果在2.0.2版本中,如果你输入一个已经存在的项目名,则系统会提示你,已经存在同名,不允许你创建并退出。另外一定要注意,这一步是运行文件 @H_403_5@@H_403_5@@H_403_5@@H_403_5@create-android-project.bat而不是另一个相同主文件名的@H_403_5@@H_403_5@@H_403_5@create-android-project.sh!!!-----这个文件后面才使用; 否则整个步骤乱套了!!! @H_403_5@
@H_403_5@@H_403_5@
@H_403_5@
我的例子中创建的WIN32项目为eee2,这里创建的ANDROID工程名称为eee21。之后,系统自动运行,并创建项目,其下有三个子文件夹:Classes,proj.android和Resources。
@H_403_5@@H_403_5@@H_403_5@

@H_403_5@@H_403_5@STEP 3:@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@导入代码和有关资源
@H_403_5@@H_403_5@@H_403_5@@H_403_5@
现在,
@H_403_5@把你win32项目里的Classes拷贝到当前Classes下@H_403_5@@H_403_5@。然后把你win32项目里的Resources拷贝到当前@H_403_5@Resources @H_403_5@下。
提示1:2.0.2版本与1.x版本中管理资源的方式发生了较大变化,请注意这一点。当然,在高版本中,管理更为方便和科学了。
提示2:直接使用覆盖方式复制粘贴即可。另外,还要想着先把最初系统自动生成的几个可能不再有用的文件删除


@H_403_5@@H_403_5@@H_403_5@STEP 4:@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@编辑jni文件夹下的android.mk等文件
@H_403_5@@H_403_5@@H_403_5@@H_403_5@
这一步比较复杂,要求你最好深入理解application.mk和android.mk这两个文件在NDK编程中的位置及详细作用。在此不具体展开介绍了。

因为,我的例子是一个由系统向导自动生成的HELLO WORLD级的程序,所以,一路走下来非常顺利。
我的android.mk文件修改为如下形式:

@H_403_5@LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := game_shared
#LOCAL_MODULE_FILENAME := libgame

LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp


LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
$(LOCAL_PATH)/../../../cocos2dx \
$(LOCAL_PATH)/../../../cocos2dx/platform. \
$(LOCAL_PATH)/../../../cocos2dx/include \
$(LOCAL_PATH)/../../../cocosDension/include



LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static

include $(BUILD_SHARED_LIBRARY)

$(call import-module,CocosDenshion/android) \
$(call import-module,cocos2dx) \
$(call import-module,extensions)

@H_403_5@我的更改有:
1,注释掉了@H_403_5@LOCAL_MODULE_FILENAME := libgame这一句。
2,把共享库名字更改为@H_403_5@game_shared,对应于eee21.java文件中的下面一句必须作相应的修改

System.loadLibrary("game_shared"); @H_403_5@@H_403_5@@H_403_5@

3,根据我的ANDROID工程所在位置修改了头文件引用部分。 @H_403_5@@H_403_5@@H_403_5@

@H_403_5@LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
$(LOCAL_PATH)/../../../cocos2dx \
$(LOCAL_PATH)/../../../cocos2dx/platform. \
$(LOCAL_PATH)/../../../cocos2dx/include \
$(LOCAL_PATH)/../../../cocosDension/include
@H_403_5@
其中,@H_403_5@ $(LOCAL_PATH)是jni文件夹,于是相对于这一级文件夹,你的cocos2d-x系统的相应的头文件在哪一级文件夹下要明明白白才行。
另外,要注意的是,在最上面一行的\符号的后面直接跟的是一个硬回车字符。如果这个硬回车字符前面还有其他的什么空白符号的话,NDK编译到这个地方就停止了。

@H_403_5@@H_403_5@@H_403_5@@H_403_5@STEP 4:@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@运行build_native.sh脚本文件编译生成so库
@H_403_5@@H_403_5@@H_403_5@@H_403_5@
@H_403_5@根据网络的参考资料,我以系统管理员身份运行cycwin。然后运行你的系统生成的ANDROID工程内proj.android文件夹下的build_native.sh脚本文件,我的文件位置在:
E:\download2010\cocos2d-x\cocos2d-2.0-x-2.0.2\eee21\proj.android
一般是先切换到上述文件夹下,然后再运行那个脚本文件,我的命令是:
1. cd /cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/proj.android

2. ./build_native.sh
输出结果是:
NDK_ROOT = /cygdrive/d/ndkr8
COCOS2DX_ROOT = /cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/pro
j.android/../..
APP_ROOT = /cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/proj.and
roid/..
APP_ANDROID_ROOT = /cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/
proj.android
Using prebuilt externals
make: Entering directory `/cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2
/eee21/proj.android'
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Cygwin : Generating dependency file converter script
Compile++ thumb : game_shared <= main.cpp
Compile++ thumb : game_shared <= AppDelegate.cpp
Compile++ thumb : game_shared <= HelloWorldScene.cpp
Prebuilt : libgnustl_static.a <= <NDK>/sources/cxx-stl/gnu-libstdc++/libs/
armeabi/
Compile++ thumb : cocos2dx_static <= CCConfiguration.cpp
Compile++ thumb : cocos2dx_static <= CCDrawingPrimitives.cpp
Compile++ thumb : cocos2dx_static <= CCScheduler.cpp
Compile++ thumb : cocos2dx_static <= CCCamera.cpp
Compile++ thumb : cocos2dx_static <= CCAction.cpp
Compile++ thumb : cocos2dx_static <= CCActionCamera.cpp
Compile++ thumb : cocos2dx_static <= CCActionCatmullRom.cpp
Compile++ thumb : cocos2dx_static <= CCActionEase.cpp
Compile++ thumb : cocos2dx_static <= CCActionGrid.cpp
Compile++ thumb : cocos2dx_static <= CCActionGrid3D.cpp
Compile++ thumb : cocos2dx_static <= CCActionInstant.cpp
Compile++ thumb : cocos2dx_static <= CCActionInterval.cpp
Compile++ thumb : cocos2dx_static <= CCActionManager.cpp
Compile++ thumb : cocos2dx_static <= CCActionPageTurn3D.cpp
Compile++ thumb : cocos2dx_static <= CCActionProgressTimer.cpp
Compile++ thumb : cocos2dx_static <= CCActionTiledGrid.cpp
Compile++ thumb : cocos2dx_static <= CCActionTween.cpp
Compile++ thumb : cocos2dx_static <= CCAtlasNode.cpp
Compile++ thumb : cocos2dx_static <= CCNode.cpp
Compile++ thumb : cocos2dx_static <= CCAffineTransform.cpp
Compile++ thumb : cocos2dx_static <= CCGeometry.cpp
Compile++ thumb : cocos2dx_static <= CCAutoreleasePool.cpp
Compile++ thumb : cocos2dx_static <= CCDictionary.cpp
Compile++ thumb : cocos2dx_static <= CCNS.cpp
Compile++ thumb : cocos2dx_static <= CCObject.cpp
Compile++ thumb : cocos2dx_static <= CCSet.cpp
Compile++ thumb : cocos2dx_static <= CCString.cpp
Compile++ thumb : cocos2dx_static <= CCZone.cpp
Compile++ thumb : cocos2dx_static <= CCArray.cpp
Compile++ thumb : cocos2dx_static <= cocos2d.cpp
Compile++ thumb : cocos2dx_static <= CCDirector.cpp
Compile++ thumb : cocos2dx_static <= CCGrabber.cpp
Compile++ thumb : cocos2dx_static <= CCGrid.cpp
Compile thumb : cocos2dx_static <= aabb.c
Compile thumb : cocos2dx_static <= mat3.c
Compile thumb : cocos2dx_static <= mat4.c
Compile thumb : cocos2dx_static <= neon_matrix_impl.c
Compile thumb : cocos2dx_static <= plane.c
Compile thumb : cocos2dx_static <= quaternion.c
E:/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/proj.android/../../cocos2dx/
kazmath/src/quaternion.c: In function 'kmQuaternionAssign':
E:/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/proj.android/../../cocos2dx/
kazmath/src/quaternion.c:478: warning: incompatible implicit declaration of buil
t-in function 'memcpy'
Compile thumb : cocos2dx_static <= ray2.c
Compile thumb : cocos2dx_static <= utility.c
Compile thumb : cocos2dx_static <= vec2.c
Compile thumb : cocos2dx_static <= vec3.c
Compile thumb : cocos2dx_static <= vec4.c
E:/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/proj.android/../../cocos2dx/
kazmath/src/vec4.c: In function 'kmVec4Assign':
E:/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/proj.android/../../cocos2dx/
kazmath/src/vec4.c:150: warning: incompatible implicit declaration of built-in f
unction 'memcpy'
Compile thumb : cocos2dx_static <= mat4stack.c
Compile thumb : cocos2dx_static <= matrix.c
Compile++ thumb : cocos2dx_static <= CCKeypadDelegate.cpp
Compile++ thumb : cocos2dx_static <= CCKeypadDispatcher.cpp
Compile++ thumb : cocos2dx_static <= CCLabelAtlas.cpp
Compile++ thumb : cocos2dx_static <= CCLabelBMFont.cpp
Compile++ thumb : cocos2dx_static <= CCLabelTTF.cpp
Compile++ thumb : cocos2dx_static <= CCLayer.cpp
Compile++ thumb : cocos2dx_static <= CCScene.cpp
Compile++ thumb : cocos2dx_static <= CCTransitionPageTurn.cpp
Compile++ thumb : cocos2dx_static <= CCTransition.cpp
Compile++ thumb : cocos2dx_static <= CCTransitionProgress.cpp
Compile++ thumb : cocos2dx_static <= CCMenu.cpp
Compile++ thumb : cocos2dx_static <= CCMenuItem.cpp
Compile++ thumb : cocos2dx_static <= CCMotionStreak.cpp
Compile++ thumb : cocos2dx_static <= CCProgressTimer.cpp
Compile++ thumb : cocos2dx_static <= CCRenderTexture.cpp
Compile++ thumb : cocos2dx_static <= CCParticleExamples.cpp
Compile++ thumb : cocos2dx_static <= CCParticleSystem.cpp
Compile++ thumb : cocos2dx_static <= CCParticleBatchNode.cpp
Compile++ thumb : cocos2dx_static <= CCParticleSystemQuad.cpp
Compile++ thumb : cocos2dx_static <= CCSAXParser.cpp
Compile++ thumb : cocos2dx_static <= CCThread.cpp
Compile++ thumb : cocos2dx_static <= platform.cpp
Compile++ thumb : cocos2dx_static <= CCEGLViewProtocol.cpp
Compile++ thumb : cocos2dx_static <= CCEGLView.cpp
Compile++ thumb : cocos2dx_static <= CCAccelerometer.cpp
Compile++ thumb : cocos2dx_static <= CCApplication.cpp
Compile++ thumb : cocos2dx_static <= CCCommon.cpp
Compile++ thumb : cocos2dx_static <= CCFileUtils.cpp
Compile++ thumb : cocos2dx_static <= CCImage.cpp
Compile++ thumb : cocos2dx_static <= EditBoxJni.cpp
Compile++ thumb : cocos2dx_static <= JniHelper.cpp
Compile++ thumb : cocos2dx_static <= IMEJni.cpp
Compile++ thumb : cocos2dx_static <= MessageJni.cpp
Compile++ thumb : cocos2dx_static <= SensorJni.cpp
Compile++ thumb : cocos2dx_static <= SystemInfoJni.cpp
Compile++ thumb : cocos2dx_static <= TouchesJni.cpp
Compile++ thumb : cocos2dx_static <= CCScriptSupport.cpp
Compile++ thumb : cocos2dx_static <= ccShaders.cpp
Compile++ thumb : cocos2dx_static <= CCGLProgram.cpp
Compile++ thumb : cocos2dx_static <= ccGLStateCache.cpp
Compile++ thumb : cocos2dx_static <= CCShaderCache.cpp
Compile++ thumb : cocos2dx_static <= CCAnimation.cpp
Compile++ thumb : cocos2dx_static <= CCAnimationCache.cpp
Compile++ thumb : cocos2dx_static <= CCSprite.cpp
Compile++ thumb : cocos2dx_static <= CCSpriteBatchNode.cpp
Compile++ thumb : cocos2dx_static <= CCSpriteFrame.cpp
Compile++ thumb : cocos2dx_static <= CCSpriteFrameCache.cpp
Compile++ thumb : cocos2dx_static <= CCNotificationCenter.cpp
Compile++ thumb : cocos2dx_static <= CCProfiling.cpp
Compile++ thumb : cocos2dx_static <= CCPointExtension.cpp
Compile++ thumb : cocos2dx_static <= TransformUtils.cpp
Compile++ thumb : cocos2dx_static <= CCUserDefault.cpp
Compile++ thumb : cocos2dx_static <= base64.cpp
Compile++ thumb : cocos2dx_static <= ccUtils.cpp
Compile++ thumb : cocos2dx_static <= CCVertex.cpp
Compile++ thumb : cocos2dx_static <= ccCArray.cpp
Compile++ thumb : cocos2dx_static <= TGAlib.cpp
Compile++ thumb : cocos2dx_static <= ZipUtils.cpp
Compile++ thumb : cocos2dx_static <= ioapi.cpp
Compile++ thumb : cocos2dx_static <= unzip.cpp
Compile++ thumb : cocos2dx_static <= CCIMEDispatcher.cpp
Compile++ thumb : cocos2dx_static <= CCTextFieldTTF.cpp
Compile++ thumb : cocos2dx_static <= CCTexture2D.cpp
Compile++ thumb : cocos2dx_static <= CCTextureAtlas.cpp
Compile++ thumb : cocos2dx_static <= CCTextureCache.cpp
Compile++ thumb : cocos2dx_static <= CCTexturePVR.cpp
Compile++ thumb : cocos2dx_static <= CCParallaxNode.cpp
Compile++ thumb : cocos2dx_static <= CCTMXLayer.cpp
Compile++ thumb : cocos2dx_static <= CCTMXObjectGroup.cpp
Compile++ thumb : cocos2dx_static <= CCTMXTiledMap.cpp
Compile++ thumb : cocos2dx_static <= CCTMXXMLParser.cpp
Compile++ thumb : cocos2dx_static <= CCTileMapAtlas.cpp
Compile++ thumb : cocos2dx_static <= CCTouchDispatcher.cpp
Compile++ thumb : cocos2dx_static <= CCTouchHandler.cpp
Compile++ thumb : cocos2dx_static <= CCTouch.cpp
Prebuilt : png.a <= /cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2
/eee21/proj.android/../../cocos2dx/platform/third_party/android/prebuilt/libpng/
libs/armeabi/
Prebuilt : jpeg.a <= /cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.
2/eee21/proj.android/../../cocos2dx/platform/third_party/android/prebuilt/libjpe
g/libs/armeabi/
Prebuilt : xml2.a <= /cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.
2/eee21/proj.android/../../cocos2dx/platform/third_party/android/prebuilt/libxml
2/libs/armeabi/
Prebuilt : tiff.a <= /cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.
2/eee21/proj.android/../../cocos2dx/platform/third_party/android/prebuilt/libtif
f/libs/armeabi/
StaticLibrary : libcocos2d.a
Compile++ thumb : cocosdenshion_static <= SimpleAudioEngine.cpp
Compile++ thumb : cocosdenshion_static <= SimpleAudioEngineJni.cpp
Compile++ thumb : cocosdenshion_static <= OpenSLEngine.cpp
E:/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/proj.android/../../CocosDens
hion/android/opensl/OpenSLEngine.cpp: In function 'bool initAudioPlayer(AudioPla
yer*,const char*)':
E:/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/proj.android/../../CocosDens
hion/android/opensl/OpenSLEngine.cpp:292: warning: extended initializer lists on
ly available with -std=c++0x or -std=gnu++0x
E:/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/proj.android/../../CocosDens
hion/android/opensl/OpenSLEngine.cpp:292: warning: extended initializer lists on
ly available with -std=c++0x or -std=gnu++0x
Compile++ thumb : cocosdenshion_static <= SimpleAudioEngineOpenSL.cpp
StaticLibrary : libcocosdenshion.a
Compile++ thumb : cocos_extension_static <= CCBFileLoader.cpp
Compile++ thumb : cocos_extension_static <= CCBReader.cpp
E:/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/eee21/proj.android/../../extension
s/CCBReader/CCBReader.cpp:141:52: warning: multi-character character constant
Compile++ thumb : cocos_extension_static <= CCControlButtonLoader.cpp
Compile++ thumb : cocos_extension_static <= CCControlLoader.cpp
Compile++ thumb : cocos_extension_static <= CCLabelBMFontLoader.cpp
Compile++ thumb : cocos_extension_static <= CCLabelTTFLoader.cpp
Compile++ thumb : cocos_extension_static <= CCLayerColorLoader.cpp
Compile++ thumb : cocos_extension_static <= CCLayerGradientLoader.cpp
Compile++ thumb : cocos_extension_static <= CCLayerLoader.cpp
Compile++ thumb : cocos_extension_static <= CCMenuItemImageLoader.cpp
Compile++ thumb : cocos_extension_static <= CCMenuItemLoader.cpp
Compile++ thumb : cocos_extension_static <= CCNodeLoader.cpp
Compile++ thumb : cocos_extension_static <= CCNodeLoaderLibrary.cpp
Compile++ thumb : cocos_extension_static <= CCParticleSystemQuadLoader.cpp
Compile++ thumb : cocos_extension_static <= CCScale9SpriteLoader.cpp
Compile++ thumb : cocos_extension_static <= CCScrollViewLoader.cpp
Compile++ thumb : cocos_extension_static <= CCSpriteLoader.cpp
Compile++ thumb : cocos_extension_static <= CCControl.cpp
Compile++ thumb : cocos_extension_static <= CCControlButton.cpp
Compile++ thumb : cocos_extension_static <= CCControlColourPicker.cpp
Compile++ thumb : cocos_extension_static <= CCControlHuePicker.cpp
Compile++ thumb : cocos_extension_static <= CCControlSaturationBrightnessPicker
.cpp
Compile++ thumb : cocos_extension_static <= CCControlSlider.cpp
Compile++ thumb : cocos_extension_static <= CCControlSwitch.cpp
Compile++ thumb : cocos_extension_static <= CCControlUtils.cpp
Compile++ thumb : cocos_extension_static <= CCInvocation.cpp
Compile++ thumb : cocos_extension_static <= CCMenuPassive.cpp
Compile++ thumb : cocos_extension_static <= CCScale9Sprite.cpp
Compile++ thumb : cocos_extension_static <= CCSpacer.cpp
Compile++ thumb : cocos_extension_static <= CCScrollView.cpp
Compile++ thumb : cocos_extension_static <= CCEditBox.cpp
Compile++ thumb : cocos_extension_static <= CCEditBoxImplAndroid.cpp
Compile++ thumb : cocos_extension_static <= HttpClient.cpp
Prebuilt : curl.a <= /cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.
2/eee21/proj.android/../../cocos2dx/platform/third_party/android/prebuilt/libcur
l/libs/armeabi/
StaticLibrary : libextension.a
SharedLibrary : libgame_shared.so
Install : libgame_shared.so => libs/armeabi/libgame_shared.so
make: Leaving directory `/cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.2/
eee21/proj.android'

Administrator@Xianzhong-PC /cygdrive/e/download2010/cocos2d-x/cocos2d-2.0-x-2.0.
2/eee21/proj.android


注意:其中有几处警告性提示--这个以后再学习。总之,顺利生成了libs文件夹下的.so文件


@H_403_5@@H_403_5@@H_403_5@@H_403_5@STEP 5:@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@使用ECLIPSE再编译并打包到真机测试
@H_403_5@@H_403_5@@H_403_5@@H_403_5@

@H_403_5@@H_403_5@启动Eclipse,使用File -> New -> Project...在随后的"New Project"对话框中选择Android->Android project from existing code,如下所示:


@H_403_5@
随后出现导入工程对话框,类似(来自于另一个实例)下图所示:

@H_403_5@

导入(浏览文件夹时选择
@H_403_5@@H_403_5@到proj.android这一层)成功,然后就是编译执行了。

@H_403_5@cocos2d-x作者推荐用上面的.sh方式编译生成.so库文件,然后再用eclipse编译成.apk文件
@H_403_5@
@H_403_5@@H_403_5@@H_403_5@@H_403_5@注意:在导入成功后,我没有作任何修改先使用重新编译了一下工程(在工程上面单击右键-构建工程),然后按Ctrl+F11运行。

下图给出了在我的真机SamSung I9100上运行的结果快照:

@H_403_5@@H_403_5@@H_403_5@
@H_403_5@@H_403_5@

@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@补充1:@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@开发环境
@H_403_5@@H_403_5@@H_403_5@@H_403_5@
我的开发环境是:
WINDOWS 7
ECLIPSE Indigo Service Release 2
CYGWIN
NDK 8
vs2010
最新版本的cocos2d-x 2.0.2(上述操作同样适用于到当前最新版本2.1Beta3)。


@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@补充2:@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@在2.1Beta3下导入到Eclipse的一个细节
@H_403_5@@H_403_5@@H_403_5@@H_403_5@
我喜欢跟踪使用最新的COCOS2D-X的开发环境。可是,在目前最新的2.1Beta3 SDK对应的WIN32工程导入到Eclipse中时,在导入结束,工程左边显示一个大大的红色的感叹号。进入到工程属性窗口中发现,工程引入了另外一个工程Java,如下图所示:

@H_403_5@@H_403_5@

此时,一般需要重新把系统自动导入的java工程构建一下。然后,再把你的游戏工程再构建一下即可。
另外:在cocos2d-2.1beta3-x-2.1.1版本中也有与上面一样的规律,我现在(2013.2.6)刚刚使用过,OK!

@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@补充3:@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@@H_403_5@在2.1Beta3下运行build_native.sh生成的src文件夹下的java文件
@H_403_5@@H_403_5@@H_403_5@@H_403_5@
这个JAVA文件内容也简单多了,我在最近使用的小型试验型工程中相应的文件内容如下:

/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org

http://www.cocos2d-x.org

Permission is hereby granted,free of charge,to any person obtaining a copy
of this software and associated documentation files (the "Software"),to deal
in the Software without restriction,including without limitation the rights
to use,copy,modify,merge,publish,distribute,sublicense,and/or sell
copies of the Software,and to permit persons to whom the Software is
furnished to do so,subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS",WITHOUT WARRANTY OF ANY KIND,EXPRESS OR
IMPLIED,INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER
LIABILITY,WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE,ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.zxz.HellosqliteA;

import org.cocos2dx.lib.Cocos2dxActivity;

import android.os.Bundle;

public class HellosqliteA extends Cocos2dxActivity{

protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}

static {
System.loadLibrary("game_shared");
}
}


@H_403_5@@H_403_5@@H_403_5@@H_403_5@不用作任何修改即可。
最后,文件夹proj.android\jni\hellocpp下系统自动生成的main.cpp头文件引用中的下面一行一般要去掉的(根据你的情况吧):
#include "HelloworldScene.h"


无标题.jpg

无标题.jpg

无标题.jpg

捕获.JPG

猜你在找的Cocos2d-x相关文章