Created
January 14, 2015 01:34
-
-
Save prespondek/0d8e21a61963ee7a4786 to your computer and use it in GitHub Desktop.
JNI Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.my.package; | |
import org.cocos2dx.lib.Cocos2dxHelper; | |
import org.cocos2dx.lib.Cocos2dxActivity; | |
public class JNIExample | |
{ | |
static public void JavaFromCpp(String java_str, String [] java_array, boolean flag) | |
{ | |
// run on cocos thread | |
Cocos2dxHelper.getActivity().runOnUiThread(new Runnable() { | |
public void run() { | |
// do something | |
} | |
}); | |
} | |
static public void JavaToCpp(String str, float num) { | |
// run on cocos thread | |
((Cocos2dxActivity)Cocos2dxHelper.getActivity()).runOnGLThread(new Runnable() { | |
public void run() { | |
JavaToCpp(str,num); | |
} | |
}); | |
} | |
// notice "native" keyword here. | |
public static native void CppFromJava(String str, float num) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment