GameTools javaLink

From Wikiid
Jump to: navigation, search

Eases the pain of working with Java scripting inside a C++ environment. Create a class JavaLink object for each script, passing in the file name and path to the Java source code. Remember that the filename of the Java script must be the same as the name of the object inside it.

 class JavaLink
 {
   JavaLink ( const char *_fname, const char *_path ) ;
   void callConstructor () ;
   ~JavaLink () ;
   static void *makeParameterArray ( int numElements ) ;
   static void  freeParameterArray ( void *parameterArray ) ;
   static void  setParameter ( void *parameterArray, int which, bool          value ) ;
   static void  setParameter ( void *parameterArray, int which, char          value ) ;
   static void  setParameter ( void *parameterArray, int which, unsigned char value ) ;
   static void  setParameter ( void *parameterArray, int which, short         value ) ;
   static void  setParameter ( void *parameterArray, int which, int           value ) ;
   static void  setParameter ( void *parameterArray, int which, long          value ) ;
   static void  setParameter ( void *parameterArray, int which, float         value ) ;
   static void  setParameter ( void *parameterArray, int which, double        value ) ;
   void *getMethod ( const char *name, const char *signature ) ;
   void callMethod ( void *methodID, void *parameterArray ) ;
   void *getVoidMethod ( const char *name )
   void callVoidMethod ( void *methodID ) ;
 } ;

The JavaLink::callConstructor() function calls the Java code for the object's constructor function. Each method (class member function) within the Java code may then be found using 'getMethod' to return a method identification 'handle' (a void* pointer in reality) - which is subsequently passed to callMethod with an array of parameters.

In our games, all Java script functions take no parameters and return no results - so getVoidMethod and callVoidMethod suffice for our needs.


Wikiid Pages relating to gameTools (edit)
gameTools - Main page
gameTools - Support Tools :
plb_to_ac3d, mklevel, mktile, mktree, tiled, autogen_java, mk3dgallery
gameTools - File Formats :
title_screen.rgb, ultimate.xml, material.xml, decoration.xml, physics.xml
tiled.xml, tiled_autotiles.xml, Level files, Tile naming scheme, PLB files
gameTools - Source Code :
Game functions: gameCamera, gameClock, gameChecksum/gameHashTable, gameHTTP,
gameIsect, gameJoystick, gameParticleManager, gameScreen/gameMouse,
gameSky, gameStarter, gameStrokeFont, gameUtils
Material database: MatList/MatEntry
Tile map handling: TileObject/MapFlag/MapEntry/Map
Java Interfacing: JavaLink
Image file loading: liImage/liImageFactory
3D Model file loading: loadPLB, PLB exporter
Physics: Sabot, Bullet, gameTools - Use with Blender, PLB exporter
Object management: Object


Wikiid Pages relating to Lemur of Lima (edit)
Lemur of Lima - Main page
Lemur of Lima - Controls
Lemur of Lima - Levels :
List of Levels, Level design, Screen shots, Models
Lemur of Lima - Java Plugins :
Java plugin API, Event handling, Flags, GameInterface API , Alphabetical Index
Lemur of Lima - Source Code Documentation :
Initialisation, Main Loop, gameTools