Cocos2d-x Tutorial (-ios) porting Android

Source: Internet
Author: User

Welcome to join the Cocos2d-x Exchange Group: 193411763


When reproduced, please indicate the original source: http://blog.csdn.net/u012945598/article/details/44338659


--------------------------------------------------------------------------------------------------------------- --------------------------------------------

The author's development environment:

Mac OS X 10.9.5

Cocos2d-x 3.3 final version

Xcode 6.1.1 version

This article mainly records the author's problems encountered in the transplant.


(1) Modify the Android.mk file

The author's project is based on Lua, as mentioned in the previous article, Lua Engineering and C + + engineering file structure is not the same, relative to the C + + engineering porting steps is simpler. Whether it's a C + + engineering or LUA project, modifying a android.mk file is a must, and the directory of this file is located in the LUA Project: Projects Engineering Files/frameworks/runtime-src/proj.android/jni/ Android.mk. The C + + project directly opens the project project file to see the Proj.android folder.


You can compare, an empty C + + HelloWorld project and an empty LUA project, the difference between the Android.mk file, here I only give the author of the final project Android.mk file for your reference (based on the LUA project, C + + may need to make some changes).

Local_path: = $ (call My-dir) include $ (clear_vars) Local_module: = Cocos2dlua_sharedlocal_module_filename: = Libcocos2dluadefine Walk $ (wildcard $ (1)) $ (foreach e,$ (wildcard $ (1)/*), $ (call walk,$ (e))) Endefallfiles = $ (Call walk,$ (Local_path)/. /.. /classes) File_list: = Hellolua/main.cppfile_list + = $ (Filter%.cpp,$ (allfiles)) File_list + = $ (Filter%.c,$ (allfiles)) File_includes: = $ (Shell find $ (local_path)/. /.. /classes-type d) Local_src_files: = $ (file_list:$ (Local_path)/%=%) Local_c_includes: = $ (local_path)/... /.. /classeslocal_c_includes + = $ (Shell ls-fr $ (local_c_includes) | grep $ (local_path)/$) Local_c_includes: = $ (LOCAL_C_INCL udes:$ (Local_path)/%:=$ (local_path)/%) Local_static_libraries: = cocos2d_lua_staticlocal_static_libraries + = Cocostudio_staticlocal_static_libraries + = Cocos2dx_staticinclude $ (build_shared_library) $ (call Import-module, scripting/lua-bindings/proj.android)

above is the author's current project in the complete android.mk file.


(2) The problem of not finding the head file at compile time


(3) Customizing LUA binding issues.

Open the project file name/frameworks/cocos2d-x/cocos/scripting/lua-bindings/proj.android/android.mk

All C + + files that need to be compiled in the Lua_bindings engineering file are done in this MK file, and all we need to do is to add our custom mapping files to it in the appropriate location, such as:


(4) Mapping File reference header file problem

      In our custom mapping file, it is necessary to refer to the CPP file under the Classes folder in the project, if here we just write #include "xxx.h" in iOS is no problem, but at compile time, You will also be prompted not to find this xxx file. The need to add here is the full path of the file, such as you want to introduce the Xxx.h file, find this file, right-click on the introduction, the path shown is the path we want to write here. The best way to do this is to write a method to get the full path of the file, otherwise if the write is dead locally in version management There will be a problem.


(5) Resource file name

      Resources in iOS Although you can use Chinese names, but normal people know not to use Chinese name, although there is no problem in iOS, but in the cross-compilation of the use of Chinese named resources will also be an error.


(6). c Files

      The author's first question, one of which is written: File_list + = $ (Filter%.c,$ (allfiles))

This is due to the author of the project using the Cjson Library, and Cjson in the use of C source files, so we compile the only C + + compilation is not enough, but also to compile the. c file, otherwise it will not be used.

Cocos2d-x Tutorial (-ios) porting Android

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.