Book Image

Building Android Games with Cocos2d-x

By : Raydelto Hernandez
Book Image

Building Android Games with Cocos2d-x

By: Raydelto Hernandez

Overview of this book

Table of Contents (16 chapters)
Building Android Games with Cocos2d-x
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding the JNI capabilities


JNI offers a bridge between the C++ code and the Java code. The Cocos2d-x framework provides us with a JNI helper, which makes it easier to integrate the C++ code and the Java code.

The JniHelper C++ class has a method called getStaticMethodInfo. This receives as parameters, a JniMethodInfo object to store all the data that is required to invoke the corresponding Java code, the class name where the static method is located, the name of the method, and its signature.

In order to find out the method signature for JNI, you could use the javap command: so, for instance, if we would like to know what the signatures of the methods contained in the AppActivity class are , then we just need to open a console window , go to your proj.android\bin\classes directory, and type the following command:

SET CLASSPATH=.
javap -s org.cocos2dx.cpp.AppActivity

In this particular case you will receive as a response, the signature of the null constructor created automatically for...