Cocos2d-x Android platform porting

Source: Internet
Author: User

Cocos2d-x Android platform porting 1. Tools and Environment

Operating System: WinXP, Win7

Tested mobile phone: HTC Desire S (android 4.0.3)

Development tools: cocos2d-x-2.2.2, VS2010, active-python27, adt-bundle-windows-x86-20131030 (API19), android-ndk-r9c (do not need cygwin)

Software Installation Directory: D: \ programs

2. Windows platform development steps

1) VS2010 Debug compile D: \ programs \ cocos2d-x-2.2.2 \ cocos2d-x-2.2.2 under the directory of the cocos2d-win32.vc2010 project;

2) After all the cocos2d library files are compiled, enter the D: \ programs \ cocos2d-x-2.2.2 \ cocos2d-x-2.2.2 \ tools \ project-creator directory, command line to execute python create_project.py-projectPlay-package com. xyz. create a project using play-language cpp;

3) under the Directory D: \ programs \ cocos2d-x-2.2.2 \ cocos2d-x-2.2.2 \ projects find the just-created Project Play, enter the proj. win32 Directory, compile Play. sln with VS2010;

4) after compilation, you can perform game development and debugging on the windows platform. during the development process, the resource files are placed under the Resources Directory of the project, and the code files are placed under the Classes directory;

5) after the game development test is completed, you can port the Android platform.

3. Steps for porting the Android platform

1) Configure ADT, punch menu Window-> Preferences-> Android-> NDK, configure NDK Location: D:/programs/android-ndk-r9c;

2) Import Existing Android codeinto workspace, select D: \ programs \ cocos2d-x-2.2.2 \ cocos2d-x-2.2.2 \ cocos2dx \ platform \ android \ java directory, Import the project libcocos2dx (do not select copy projects into workspace );

3) Import the just-created Project Play, directory in D: \ programs \ cocos2d-x-2.2.2 \ cocos2d-x-2.2.2 \ projects \ Play \ proj. android (do not select copy projects into workspace) This project references the libcocos2dx library by default. You can see it in Properties-> Android. If you select copy projects into workspace, after the path is changed, the original dependency of the project created by cocos2dx is damaged;

4) set project properties, select Propertices-> C/C ++ Build, Build command changed to: D:/programs/android-ndk-r9c/ndk-build.cmd;

5) Select Propertices-> C/C ++ Build-> Environment, add Variable: NDK_MODULE_PATH, value: D:/Programs/cocos2d-x-2.2.2/cocos2d-x-2.2.2; D: /Programs/cocos2d-x-2.2.2/cocos2d-x-2.2.2/cocos2dx/platform/third_party/android/prebuilt;

6) Modify jni/Android. mk and add two red lines to $ (call import-module, cocos2dx ).

$ (Call import-add-path, D:/Programs/cocos2d-x-2.2.2/cocos2d-x-2.2.2)

$ (Call import-add-path, D:/Programs/cocos2d-x-2.2.2/cocos2d-x-2.2.2/cocos2dx/platform/third_party/android/prebuilt)

$ (Callimport-module, cocos2dx)

7) Modify jni/Android. mk and add your own source code file in LOCAL_SRC_FILES;

8) Modify jni/Application. mk and add a line at the end.NDK_MODULE_PATH: = D:/Programs/cocos2d-x-2.2.2/cocos2d-x-2.2.2; D:/Programs/cocos2d-x-2.2.2/cocos2d-x-2.2.2/cocos2dx/platform/third_party/android/prebuilt

9) Copy all the resource files in Resources to the assets Directory of the android project. If there is no assets Directory, create one;

10) Select C/C ++ for Open Perspective in the upper-right corner of the ADT, click Build in the toolbar, and wait for the compilation to complete. It takes a long time (about 15 minutes );

11) Console prompt after compilation is complete

[Armeabi] Install: libcocos2dcpp. so => libs/armeabi/libcocos2dcpp. so

* *** Build Finished ****

12) connect to the Android device and Run the Play project Run As AndroidApplication. Wait until the installation is complete and the Android platform is transplanted.


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.