Aegidius
 Plüss   Aplulogo
     
 www.aplu.ch      Print Text 
© 2021, V10.4
 
  JDroidLib
 


How to port JGameGrid Java SE programs to Android
and vice-versa

Major differences between JGameGrid and JDroidLib program development :

JGameGrid (Java SE) JDroidLib (Android)
Package statement may be omitted Package statement with at least two dots mandatory

Import statement:
import ch.aplu.jgamegrid.*;

Import statement:
import ch.aplu.android.*;
Colors are objects of class java.awt.Color; color constants upper- or lowercase, color creation using constructor Color(int r, int g, int b) Colors are integers; color constants uppercase, color creating using static method Color.rgb(int r, int g, int b)
Mouse actions with class GGMouse Touch actions with class GGTouch
Mouse events with left and right mouse buttons (constants lPress, rPress, etc.) Touch events with one finger tap (constants press, longPress, etc.)
Mouse event callback mouseEvent(GGMouse mouse); mouse coordinates: mouse.getX(), etc. Touch event callback touchEvent(GGTouch touch); touch coordinates, touch.getX(), etc.
Register GGMouseListener with addMouseListener() Register GGTouchListener with addTouchListener()
Overloaded constructors of class GameGrid differ. Constructor defines the game window layout (grid or pixel game) and if a navigation area is included Overloaded constructors of class GameGrid differ. Constructor defines the screen layout (grid or pixel game, position and size of the active window, auto zoom to current device resolution), behavior when device changes orientation and if the hardware buttons can be used for navigation

Application class normally derived from GameGrid. No special restriction of method calls in constructor code

Entry point public static void main() used for application creation

Application class normally derived from GameGrid. No graphics methods call allowed in constructor code (because graphics system not yet fully initialized)

main() is automatically called by a separate thread after the graphics system is fully initialized. Can be considered as entry point

No public static void main() needed

Instance variables (fields) normally initialized when declared Initializing of most instance variables of JDroidLib classes not allowed when declared, because the graphics system is not yet fully operational at this time. Such instance variables must be initialized in main()
To display the game window, call GameGrid.show() The game window is displayed automatically, no GameGrid.show()
GameGrid.setTitle() displays text in the window title bar GameGrid.setTitle() is useless, should be replaced by GameGrid.setStatusText() or GameGrid.showToast()

GUI components with Java Swing API or Java AWT classes

Swing und AWT do not exist. Graphics and GUI classes are part of the specific Android API
Simple user input/output with JOptionPane Simple user input/output with GGInputDialog or GameGrid.requestXXX()
Sprite image files loaded from JAR, local file system or remote URL. No restriction to file name Sprite image files loaded from APK must reside in <projectroot>/res/drawable. No file extension and only lowercase letters, numbers and underline allowed. Images may get loaded from SD card

Separate status bar available (at bottom of GameGrid window). Text output with GGTextField, TextActor

 

No status bar available. Text output with toast or GGTextField, TextActor
Simple IDE project setup, just add JGameGrid.jar as external library IDE project setup complicated (external JAR, AndroidManifest.xml, layouts, etc.) Much simplified through ProjectBuilder application (included in JDroidLib distribution)
No signature needed Apps must be signed with a keystore key (producible with no fee)
V1.05