Android app Embedded COCOSX game Project

Source: Internet
Author: User

COCOS2DX's Android Environment build (WINDOWS/MAC)

I used the cocos2dx3.15 version of the.

The following steps are performed on the Windows platform.

Create a Cocos2d-x Project

Unzip the cocos2dx3.15 compressed package you just downloaded into the folder you specified.

Go to directory cocos2d-x-3.15/tools/cocos2d-console/bin/cocos.py

Open terminal Run cocos.py script Create file

Python cocos.py new test-p com.coco2dx.org-l cpp-d ~/desktop

Parameter description:

    • Test is the project name
    • -pAfter the package name
    • -lfollowed by the development of the language type, there are CPP, LUA, JS three types
    • -dThe directory after which the project is stored
Compiling the libcocos2dlua.so file

Eclipse (not recommended, Google has abandoned eclipse)

  • Create an empty Android project (my project is TESTANDROIDCC)
  • Into the proj.android of the COCOS2DX project that was just created目录下(我的是:D:\workspace\Cocos2dx_Pro\JXKJ_GAME\frameworks\runtime-src\proj.android)
  • Open Terminal, execute Cocos compile-p android-android (because Cocos canceled execution build_ native.py the way the script is compiled, unified with the Cocos command, the environment is configured to directly execute the Cocos command, if the COCOS2DX command is not found, indicating a problem with the environment configuration, or you can execute Python D:\cocos2d-x\ cocos2d-x-3.15\tools\cocos2d-console\bin\cocos.py compile-p android-android
  • After the compilation is complete, locate the libcocos2dlua.so file (under the Libs/armeabi directory)
  • Copy the folder where the so file was just compiled into the Libs folder under the TESTANDROIDCC directory
  • Copy the COCOS2DX Resource directory (res and SRC folders) to the assets directory of the TESTANDROIDCC
  • Copy the org file from the cocos2dx3.15 engine D:\cocos2d-x\cocos2d-x-3.15\cocos\platform\android\java\src directory to the TESTANDROIDCC/SRC directory
  • Create a new activity file in the Mainactivity.java's sibling directory (name your own definition, mine is gameactivity) inherit cocos2dxactivity (Don't forget to import the package imports org.cocos2dx.lib.Cocos2dxActivity;)
  • Add configuration to new activity in Androidmanifest.xml, add register new Gameactivity
  • Refer to the Androidmanifest.xml file of the COCOS2DX game project to make changes to TESTANDROIDCC Androidmanifest.xml
  • Add a button to the Activity_main.xml layout and add the event to the button in the Mainactivity
  • Compile run TESTANDROIDCC, I'm using the night God Simulator

Android Studio

  • Create an empty Android project (my project is testandroid)
  • Into the proj.android-studio of the COCOS2DX project that was just created目录下(我的是:D:\workspace\Cocos2dx_Pro\JXKJ_GAME\frameworks\runtime-src\proj.android-studio)
  • Open Terminal, execute Cocos compile-p android--android-studio (because Cocos canceled execution build_ native.py the way the script is compiled, unified with the Cocos command, the environment is configured to directly execute the Cocos command, if the COCOS2DX command is not found, indicating a problem with the environment configuration, or you can execute Python D:\cocos2d-x\ cocos2d-x-3.15\tools\cocos2d-console\bin\cocos.py compile-p Android--android-studio
  • Wait for the compilation to complete, find the libcocos2dlua.so file (searched for a long time, found in D:\workspace\Cocos2dx_Pro\JXKJ_GAME\frameworks\runtime-src\ Proj.android-studio\app\build\intermediates\transforms\mergejnilibs\debug\folders\2000\1f\main\lib)
  • Create a new jnilibs in the App/src/main directory (the name must be the same letter) folder and copy the folder (Armeabi folder) where the so file is just compiled to the Jnilibs folder
  • Import Module in Testandroid project, right-click Project file-new-module-import Eclipse ADT Project Import D:\cocos2d-x\cocos2d-x-3.15\cocos\platform\ Android\java directory, LIBCOCOS2DX module import succeeded
  • To add a libcocos2dx reference to Testandroid, right-click the project file-app-dependencies add LIBCOCOS2DX
  • Copy the COCOS2DX Resource directory (res and SRC folders) to the Src/main/assets directory of testandroid (if there is no Assets folder: Right-click the app folder under testandroid item-New-folder- Assets folder creation)
  • Create a new activity file in the Mainactivity.java's sibling directory (name your own definition, mine is gameactivity) inherit cocos2dxactivity (Don't forget to import the package imports org.cocos2dx.lib.Cocos2dxActivity;)
  • Add configuration to new activity in Androidmanifest.xml, add register new Gameactivity
  • Refer to the Androidmanifest.xml file of the COCOS2DX game project to make changes to TESTANDROIDCC Androidmanifest.xml
  • Add a button to the Activity_main.xml layout and add the event to the button in the Mainactivity
  • Compile and run, I'm using the night God Simulator

Android app Embedded COCOSX game Project

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.