O'Reilly logo

Building Android Games with Cocos2d-x by Raydelto Hernandez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Adding Native Java Code

Until now, we have been creating our game by using only the programming language in which the Cocos2d-x game framework has been written (C++); nevertheless, the Android API written by Google is only available in the Java layer of the application. In this chapter, you will learn how to communicate our native C++ code with the higher end Java core by using the Java Native Interface (JNI) capabilities.

The following topics will be covered in this chapter:

  • Understanding the Cocos2d-x structure for the Android platform
  • Understanding the JNI capabilities
  • Adding the Java code to the Cocos2d-x game
  • Adding ads to the game by inserting the Java code

Understanding the Cocos2d-x structure for the Android platform

In Chapter 1

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required