Java code
Monkey Targets Forums/Android/Java code
| ||
Tell me please. Is it possible to embed Java code in the Code Monkey. If so, how. Can example. |
| ||
You can call external (extern) functions for all supported Monkey languages. Have a look at Diddy's native functions file: http://code.google.com/p/diddy/source/browse/src/diddy/externfunctions.monkey |
| ||
This is really basic module templete that use java in android development Create a folder in modules folder. Example "myjavacode" Create a file in that folder name the same as folder "myjavacode.monkey" Put this example code there: #If TARGET="android" Import "native/myjavacode.${TARGET}.${LANG}" Extern Function Power:Int(VAR:Int)="myjavacode.Power" #EndCreate a folder name "native" inside "myjavacode" Create a file in native folder name "myjavacode.android.java". This is your java code Put this example java code: //import com.bla.bla.*; class myjavacode { public static int Power(int VAR) { return VAR*VAR; } }Example your "game.monkey" that use that "myjavacode" module Import mojo Import myjavacode 'import myjavacode Class MyApp Extends App Method OnCreate() SetUpdateRate 60 End Method OnUpdate() End Method OnRender() DrawText "Call java:"+Power(12),50,50 'call myjavacode End End Function Main() New MyApp EndAll done then try compile/run android |
| ||
Why have you got you java class extending Activity? Were you planning on creating a new "screen" outside of Monkey? |
| ||
ops sorry.. edited! fyi..I'm not good in java. |