I’m struggling with calling a C*+ function in one of my classes from my main java activity. I’ve gotten JNI working the other direction, and though it’s definitely a learning curve, it’s way easier to understand calling java from C*+ than the other way around. My main problem is that there is this big “now just compile your main java class with your native functions defined using ‘javah’ and that will generate the necessary header files”. I’m having huge problems with that ‘simple’ step. But that’s another issue. I wanted to ask about the feasibility of extending cocos2d-x in the following way:
Has anyone considered creating a generic notification system on the java side (extending the Cocos2dxActivity java class for example) tied into the cocos-2d notification system? I’m imagining setting up a normal notification listener using CCNotificationCenter on the C*+ side like:
CCNotificationCenter::sharedNotificationCenter->addObserver, RESPOND_TO_URL_NOTIFICATION, NULL);
and do something on the java side like:
this.sendCplusplusNotification;
I don’t really even know if this is feasible, because of how the java types and C*+ types aren’t compatible, though it seems there should be a way to use JNI in a more generic sense. Even without passing arguments it would be really great to send basic signals back and forth without having to dig into JNI. I’m still looking for a solid example on calling C*+ from java.
BTW what I’m trying to do is have a webView on the java side call a function in one of my C*+ classes when a user has clicked on an image in the webView.