【tonyfield 2013.08.29 】
处于个人的固执,花一天时间重新布置了cocos2dx 2.1.4的目录层次,将android平台无关的代码全数裁剪,代码按模块置于 jni 下,主要分为
cocos2d, CocosDenshion, extensions, external,third_party 5个主要模块,其中 NDK中已有的 AssetManager及GLES/SLES头文件全部删除,只要包含路径含有 ${NDK_ROOT}/platforms/android-8/arch-arm/usr/include,则这些文件没必要复制在工程中。目录结构如下:
. ├── cocos2dx │ ├── actions │ ├── base_nodes │ ├── cocoa │ ├── draw_nodes │ ├── effects │ ├── include │ ├── kazmath │ │ ├── include │ │ │ └── kazmath │ │ │ └── GL │ │ └── src │ │ └── GL │ ├── keypad_dispatcher │ ├── label_nodes │ ├── layers_scenes_transitions_nodes │ ├── menu_nodes │ ├── misc_nodes │ ├── particle_nodes │ ├── platform │ │ └── android │ │ └── jni │ ├── script_support │ ├── shaders │ ├── sprite_nodes │ ├── support │ │ ├── component │ │ ├── data_support │ │ ├── image_support │ │ ├── tinyxml2 │ │ ├── user_default │ │ └── zip_support │ ├── text_input_node │ ├── textures │ ├── tilemap_parallax_nodes │ └── touch_dispatcher ├── CocosDenshion │ ├── include │ ├── jni │ └── opensl ├── extensions │ ├── AssetsManager │ ├── CCArmature │ │ ├── animation │ │ ├── datas │ │ ├── display │ │ ├── external_tool │ │ │ └── Json │ │ │ └── lib_json │ │ ├── physics │ │ └── utils │ ├── CCBReader │ ├── Components │ ├── GUI │ │ ├── CCControlExtension │ │ ├── CCEditBox │ │ └── CCScrollView │ ├── LocalStorage │ ├── network │ ├── physics_nodes │ └── spine ├── external │ ├── Box2D │ │ ├── Collision │ │ │ └── Shapes │ │ ├── Common │ │ ├── Dynamics │ │ │ ├── Contacts │ │ │ └── Joints │ │ └── Rope │ ├── chipmunk │ │ ├── include │ │ │ └── chipmunk │ │ │ └── constraints │ │ └── src │ │ └── constraints │ ├── emscripten │ ├── libwebsockets │ │ ├── include │ │ └── lib │ │ ├── armeabi │ │ ├── armeabi-v7a │ │ └── x86 │ └── sqlite3 │ ├── include │ └── libraries │ └── win32 └── third_party ├── libcurl │ ├── include │ │ └── curl │ └── libs │ ├── armeabi │ ├── armeabi-v7a │ └── x86 ├── libjpeg │ ├── include │ └── libs │ ├── armeabi │ ├── armeabi-v7a │ └── x86 ├── libpng │ ├── include │ └── libs │ ├── armeabi │ ├── armeabi-v7a │ └── x86 ├── libtiff │ ├── include │ └── libs │ ├── armeabi │ ├── armeabi-v7a │ └── x86 └── libwebp ├── include └── libs ├── armeabi ├── armeabi-v7a └── x86 119 directories
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos2dx_top LOCAL_MODULE_FILENAME := libcocos2d_top #LOCAL_WHOLE_STATIC_LIBRARIES := cocos_libpng_static #LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jpeg_static #LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libxml2_static #LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libtiff_static #LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libwebp_static COCOS2DX_PATH := $(LOCAL_PATH)/cocos2dx LOCAL_EXPORT_C_INCLUDES := $(COCOS2DX_PATH) \ $(COCOS2DX_PATH)/include \ $(COCOS2DX_PATH)/kazmath/include \ $(COCOS2DX_PATH)/platform/android # define the macro to compile through support/zip_support/ioapi.c LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API LOCAL_EXPORT_CFLAGS := -Wno-psabi -DUSE_FILE32API include $(BUILD_STATIC_LIBRARY) $(call import-module,cocos2dx) $(call import-module,CocosDenshion) $(call import-module,extensions) $(call import-module,external/Box2D) $(call import-module,external/chipmunk) $(call import-module,third_party/libcurl) $(call import-module,third_party/libjpeg) $(call import-module,third_party/libpng) $(call import-module,third_party/libtiff) $(call import-module,third_party/libwebp)
复制导入TestCpp工程
将公用类代码 /home/yourname/cocos2d-x-2.1.4/samples/Cpp/TestCpp/Classes 复制到 TestCpp/jni;
将assets资源 /home/yourname/cocos2d-x-2.1.4/samples/Cpp/TestCpp/Resources 复制到 TestCpp/assets;
添加 Eclipse 局部环境变量 COCOS2DX_ROOT 为第1节中项目的jni目录;
在项目属性中添加第1节改好的 cocos2dx库
Android.mk 改为
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := testcpp LOCAL_MODULE_FILENAME := libtestcpp LOCAL_SRC_FILES := testcpp/main.cpp \ Classes/AccelerometerTest/AccelerometerTest.cpp \ Classes/ActionManagerTest/ActionManagerTest.cpp \ Classes/ActionsTest/ActionsTest.cpp \ Classes/ActionsEaseTest/ActionsEaseTest.cpp \ Classes/ActionsProgressTest/ActionsProgressTest.cpp \ Classes/Box2DTest/Box2dTest.cpp \ Classes/Box2DTestBed/Box2dView.cpp \ Classes/Box2DTestBed/GLES-Render.cpp \ Classes/Box2DTestBed/Test.cpp \ Classes/Box2DTestBed/TestEntries.cpp \ Classes/BugsTest/Bug-1159.cpp \ Classes/BugsTest/Bug-1174.cpp \ Classes/BugsTest/Bug-350.cpp \ Classes/BugsTest/Bug-422.cpp \ Classes/BugsTest/Bug-624.cpp \ Classes/BugsTest/Bug-886.cpp \ Classes/BugsTest/Bug-899.cpp \ Classes/BugsTest/Bug-914.cpp \ Classes/BugsTest/BugsTest.cpp \ Classes/BugsTest/Bug-458/Bug-458.cpp \ Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp \ Classes/ChipmunkTest/ChipmunkTest.cpp \ Classes/ClickAndMoveTest/ClickAndMoveTest.cpp \ Classes/ClippingNodeTest/ClippingNodeTest.cpp \ Classes/CocosDenshionTest/CocosDenshionTest.cpp \ Classes/CurlTest/CurlTest.cpp \ Classes/CurrentLanguageTest/CurrentLanguageTest.cpp \ Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp \ Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp \ Classes/EffectsTest/EffectsTest.cpp \ Classes/ExtensionsTest/ExtensionsTest.cpp \ Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \ Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp \ Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \ Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \ Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \ Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp \ Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp \ Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp \ Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp \ Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp \ Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp \ Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \ \ Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ \ Classes/FontTest/FontTest.cpp \ Classes/IntervalTest/IntervalTest.cpp \ Classes/KeypadTest/KeypadTest.cpp \ Classes/LabelTest/LabelTest.cpp \ Classes/LayerTest/LayerTest.cpp \ Classes/NodeTest/NodeTest.cpp \ Classes/TextInputTest/TextInputTest.cpp \ Classes/MenuTest/MenuTest.cpp \ Classes/MotionStreakTest/MotionStreakTest.cpp \ Classes/MutiTouchTest/MutiTouchTest.cpp \ Classes/ParallaxTest/ParallaxTest.cpp \ Classes/ParticleTest/ParticleTest.cpp \ Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp \ Classes/PerformanceTest/PerformanceParticleTest.cpp \ Classes/PerformanceTest/PerformanceSpriteTest.cpp \ Classes/PerformanceTest/PerformanceTest.cpp \ Classes/PerformanceTest/PerformanceTextureTest.cpp \ Classes/PerformanceTest/PerformanceTouchesTest.cpp \ Classes/RenderTextureTest/RenderTextureTest.cpp \ Classes/RotateWorldTest/RotateWorldTest.cpp \ Classes/SceneTest/SceneTest.cpp \ Classes/SchedulerTest/SchedulerTest.cpp \ Classes/ShaderTest/ShaderTest.cpp \ Classes/SpineTest/SpineTest.cpp \ Classes/SpriteTest/SpriteTest.cpp \ Classes/TextureCacheTest/TextureCacheTest.cpp \ Classes/Texture2dTest/Texture2dTest.cpp \ Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp \ Classes/TileMapTest/TileMapTest.cpp \ Classes/TouchesTest/Ball.cpp \ Classes/TouchesTest/Paddle.cpp \ Classes/TouchesTest/TouchesTest.cpp \ Classes/TransitionsTest/TransitionsTest.cpp \ Classes/UserDefaultTest/UserDefaultTest.cpp \ Classes/ZwoptexTest/ZwoptexTest.cpp \ Classes/FileUtilsTest/FileUtilsTest.cpp \ Classes/DataVisitorTest/DataVisitorTest.cpp \ Classes/ConfigurationTest/ConfigurationTest.cpp \ Classes/controller.cpp \ Classes/testBasic.cpp \ Classes/AppDelegate.cpp \ Classes/VisibleRect.cpp #LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static #LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static #LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static #LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static #LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_C_INCLUDES := $(LOCAL_PATH)/Classes \ $(COCOS2DX_ROOT)/cocos2dx \ $(COCOS2DX_ROOT)/cocos2dx/include \ $(COCOS2DX_ROOT)/cocos2dx/kazmath/include \ $(COCOS2DX_ROOT)/cocos2dx/platform/android \ $(COCOS2DX_ROOT)/extensions \ $(COCOS2DX_ROOT)/external \ $(COCOS2DX_ROOT)/external/chipmunk/include/chipmunk \ $(COCOS2DX_ROOT)/CocosDenshion/include \ $(COCOS2DX_ROOT)/third_party/libcurl/include \ $(COCOS2DX_ROOT)/extensions/network \ $(COCOS2DX_ROOT)/external/libwebsockets/include include $(BUILD_STATIC_LIBRARY)
编译完成。值得注意的时,你不用再在mk文件末尾 添加(call import-module,external/Box2D) 语句,只要添加头文件包含路径。
【转载请注明来自blog.csdn.net/tonyfield 谢谢 2013.08.30 】