How to solve the common problems of Android porting to Cocos2d-x

Source: Internet
Author: User

1. "cocould not be resolved" occurs in functions and variables.

This problem is generally not found the header file of the cocos2d-x Declaration, in eclipse will be cocos2d header file directory introduced, including the project directory, platform/android

Add the header file to the hellocpp/main. cpp function.

#include "AppDelegate.h"#include "cocos2d.h"#include "CCEventType.h"#include "platform/android/jni/JniHelper.h"#include <jni.h>#include <android/log.h>#include "CCEGLView.h"#include "CCApplication.h"


2. Remove the three rows of numbers in the lower left corner of the screen.

Description of three rows of numbers:

The first line is the rendering batch of the current scenario.

The time required for rendering each frame in the second line

The third line is FPS.

In the AppDelegate. cpp file applicationDidFinishLaunching (), find the following line and change it to false.

    pDirector->setDisplayStats(false);

 

3. Porting android and game adaptive mobile phone screen

In the AppDelegate. cpp file applicationDidFinishLaunching () function, add the following code:

CCEGLView: Export dopenglview ()-> setDesignResolutionSize (1136,640, kResolutionShowAll); // you can specify the width, height, and mode of the resolution.

 

4. Modify the apk Application name and icon

Modify the name: eclipse project res-> values-> strings. xml file

<? Xml version = "1.0" encoding = "UTF-8"?> <Resources> <string name = "app_name"> Xiao Huang </string> </resources>

Replace icon: Replace the icons of different sizes with the png images under the drawable-* directory of the eclipse project res. The program calls the corresponding icon according to the resolution of the mobile phone.
 

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.