In Cocos2d-x, you can write one source for the cross platform. However, you have to write an Objective-C function or a Java function for the dependency process such as a purchase or push notification. If you want to call Java for Android from C++, you have to use JNI (Java Native Interface). In particular, JNI is very confusing. To call Java from C++, you have to use JNI. In this recipe, we will explain how to call an Objective-C function or a Java function from C++.
In this case, we will make a new class called
Platform. You can get the application version by using this class. Before writing code, you will make three files called Platform.h, Platform.mm, and Platform.cpp in your project.
It is important that you ...