The cocos2d project created by vs runs on Android devices and generates an apk

Source: Internet
Author: User

Create an android project under vs, see the article "Environment deployment of cocos2d-x V2.14 and later versions"

Import the project you just created with eclipse, project path: E: \ cocos2d-x-2.2.2 \ cocos2d-x-2.2.2 \ projects \ WjHelloWorld \ proj. android

 

 

 

Copy the org package under the cocos2d directory \ cocos2dx \ platform \ android \ java \ src to the src directory of the android project.

 

 

Copy and generate resources under the project path/Resource Directory to the assets under the android project directory.
E: \ cocos2d-x-2.2.2 \ cocos2d-x-2.2.2 \ projects \ WjHelloWorld \ Resources ------> E: \ cocos2d-x-2.2.2 \ cocos2d-x-2.2.2 \ projects \ WjHelloWorld \ proj. android \ assets

 

Download NDK, said to download 8C version and above, http://developer.android.com/tools/sdk/ndk/index.html

 

Right-click an android project and choose Properties C/C ++ Build. Create a Configuration in the first line.
Set the new Configuration to the project activation status

NDK path config Build command ------> E: \ android-ndk-r9c \ ndk-build.cmd

Configure Build directory ------ >$ {ProjDirPath}

 

 

 

 

Expand C/C ++ Build and find Environment add settings NDK_MODULE_PATH ------> E: \ cocos2d-x-2.2.2 \ cocos2d-x-2.2.2 \ cocos2dx \ platform \ third_party \ android \ prebuilt

 

 

In the jni folder of the Android project, locate Android. mk and edit it. Add the following content under include $ (BUILD_SHARED_LIBRARY ):
$ (Call import-add-path, E:/cocos2d-x-2.2.2/cocos2d-x-2.2.2)
$ (Call import-add-path, E:/cocos2d-x-2.2.2/cocos2d-x-2.2.2/cocos2dx/platform/third_party/android \ prebuilt)

 

 

If you are running on a virtual machine, select Use Host GPU when setting the Device on the Virtual Machine. Otherwise, an error will be reported on the virtual machine after running.

 

Effect:

 

 

 

In addition, there are two methods to create cocos2d in.

Method 1:
Run in DOS: python create_project.py-project WjHelloWorld-package com. lvchuang. test-language cpp // Where Test is the project name, com. jacky. test is the package name

Method 2:
@ Echo off
Set/p projectName = enter the Project name:
If "% projectName %" = "" goto inputError
Set/p packageName = enter the package name:
If "% packageName %" = "" goto inputError
Create_project.py-project % projectName %-package % packageName %-language cpp
Pause
Exit
: InputError
@ Echo project name or package name cannot be blank!
Pause


 

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.