第五节cocos2dx的jni部分
继续上文分析,这节来分析cocos2dx 的jni 部分: 目录为: cocos2d-x-2.1.4\cocos2dx\platform\android\jni DPIJni.cpp DPIJni.h IMEJni.cpp IMEJni.h Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp Java_org_c
继续上文分析,这节来分析cocos2dx 的jni 部分:目录为:
cocos2d-x-2.1.4\cocos2dx\platform\android\jni
DPIJni.cpp
DPIJni.h
IMEJni.cpp
IMEJni.h
Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp
Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp
Java_org_cocos2dx_lib_Cocos2dxBitmap.h
Java_org_cocos2dx_lib_Cocos2dxHelper.cpp
Java_org_cocos2dx_lib_Cocos2dxHelper.h
Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp
JniHelper.cpp
JniHelper.h
TouchesJni.cpp
DPIJni.cpp
获取屏幕DPI 的一个接口。
IMEJni.cpp
获取上层的输入设备,是否打开和关闭输入键盘
Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp
单向java 调用,传递给c++,pDirector->getAccelerometer()->update(x, y, z, timeStamp);
Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp
创建位图使用
Java_org_cocos2dx_lib_Cocos2dxHelper.cpp
帮助类,双向,java 调用c++ 和c++调用java
Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp
渲染器,单向,java 传递给c++
JniHelper.cpp
协助类,帮助接口
TouchesJni.cpp 触屏消息传递过程
参照一个为:
JNIEXPORT void JNICALL
Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin(JNIEnv * env, jobject thiz, jint id,
jfloat x, jfloat y) {
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesBegin(1,
&id, &x, &y);
}
传递给cocos2d-x-2.1.4\cocos2dx\platform\android CCEGLView.cpp 里面,这个类继承了
CCEGLViewProtocol,这个里面可以看到处理过程
void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
这个过程就完成了。
这里CCDirector.cpp 里面设置了触屏解析器
m_pobOpenGLView->setTouchDelegate(m_pTouchDispatcher);
随后CCEGLViewProtocol::handleTouchesBegin 里面调用的
m_pDelegate->touchesBegan(&set, NULL);
便会走到这里。
这一节还是讲解JNI 的本地代码与JAVA 代码之间的沟通过程,只有理解了这些概念,才能在
随后的开发过程游刃有余。
这一节就到这里,分析完毕。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use MySQL database for forecasting and predictive analytics? Overview: Forecasting and predictive analytics play an important role in data analysis. MySQL, a widely used relational database management system, can also be used for prediction and predictive analysis tasks. This article will introduce how to use MySQL for prediction and predictive analysis, and provide relevant code examples. Data preparation: First, we need to prepare relevant data. Suppose we want to do sales forecasting, we need a table with sales data. In MySQL we can use

How to implement data statistics and analysis in uniapp 1. Background introduction Data statistics and analysis are a very important part of the mobile application development process. Through statistics and analysis of user behavior, developers can have an in-depth understanding of user preferences and usage habits. Thereby optimizing product design and user experience. This article will introduce how to implement data statistics and analysis functions in uniapp, and provide some specific code examples. 2. Choose appropriate data statistics and analysis tools. The first step to implement data statistics and analysis in uniapp is to choose the appropriate data statistics and analysis tools.

Real-time log monitoring and analysis under Linux In daily system management and troubleshooting, logs are a very important data source. Through real-time monitoring and analysis of system logs, we can detect abnormal situations in time and handle them accordingly. This article will introduce how to perform real-time log monitoring and analysis under Linux, and provide corresponding code examples. 1. Real-time log monitoring Under Linux, the most commonly used log system is rsyslog. By configuring rsyslog, we can combine the logs of different applications

Statistical analysis often refers to the process of sorting, classifying and interpreting collected relevant data. The basic steps of statistical analysis include: 1. Collect data; 2. Organize data; 3. Analyze data.

Title: Analysis of the reasons and solutions for why the secondary directory of DreamWeaver CMS cannot be opened. Dreamweaver CMS (DedeCMS) is a powerful open source content management system that is widely used in the construction of various websites. However, sometimes during the process of building a website, you may encounter a situation where the secondary directory cannot be opened, which brings trouble to the normal operation of the website. In this article, we will analyze the possible reasons why the secondary directory cannot be opened and provide specific code examples to solve this problem. 1. Possible cause analysis: Pseudo-static rule configuration problem: during use

Summary of case analysis of Python application in intelligent transportation systems: With the rapid development of intelligent transportation systems, Python, as a multifunctional, easy-to-learn and use programming language, is widely used in the development and application of intelligent transportation systems. This article demonstrates the advantages and application potential of Python in the field of intelligent transportation by analyzing application cases of Python in intelligent transportation systems and giving relevant code examples. Introduction Intelligent transportation system refers to the use of modern communication, information, sensing and other technical means to communicate through

Title: Is Tencent’s main programming language Go: An in-depth analysis. As China’s leading technology company, Tencent has always attracted much attention in its choice of programming languages. In recent years, some people believe that Tencent mainly adopts Go as its main programming language. This article will conduct an in-depth analysis of whether Tencent's main programming language is Go, and give specific code examples to support this view. 1. Application of Go language in Tencent Go is an open source programming language developed by Google. Its efficiency, concurrency and simplicity are loved by many developers.

ThinkPHP6 code performance analysis: locating performance bottlenecks Introduction: With the rapid development of the Internet, more efficient code performance analysis has become increasingly important for developers. This article will introduce how to use ThinkPHP6 to perform code performance analysis in order to locate and solve performance bottlenecks. At the same time, we will also use code examples to help readers understand better. Importance of Performance Analysis Code performance analysis is an integral part of the development process. By analyzing the performance of the code, we can understand where a lot of resources are consumed
