From SimpleApplication
you inherit a special guiNode for displaying 2D elements such as text, the guiNode. Let's re-use the blue cube sample as a base.
Make a copy of
Main.java
and name the classSimpleUserInterface.java
. Remember to also refactor the first line of the main() method to:SimpleUserInterfaceapp = new SimpleUserInterface();
Before you create a custom GUI in
simpleInitApp()
, remove the default GUI from the application:public void simpleInitApp() { setDisplayStatView(false); setDisplayFps(false); ... }
Create an integer class field tracking a value; say, a distance. You want to display the value as text on the screen, so you also create a
com.jme3.font.BitmapText
class field for it:private int distance=0; private BitmapText distanceText;
In the
simpleInitApp()
method, you load a font, initialize the BitmapText object, and attach it to the guiNode.public void simpleInitApp() { ... guiFont = assetManager.loadFont("Interface/Fonts/Default...