Additionally to 2D text, a GUI can contain pictures—as decorations, icons, or status indicators. For example, a flight simulator is framed by an image of a cockpit with windows, gauges, and dials. Another use case is an inventory browser. These are just two examples—depending on your game type and genre, you encounter many different uses for icons in the GUI.
Save images for the user interface in your project's
Interface
directory.The following code sample loads a GUI element named
frame.png
and attaches it to therootNode
:Picture frame = new Picture("User interface frame"); frame.setImage(assetManager, "Interface/frame.png", false); frame.move(settings.getWidth()/2-265, 0, -2); frame.setWidth(530); frame.setHeight(10); guiNode.attachChild(frame);
The next code sample loads an icon with transparency and attaches it to the rootNode.
Picture logo = new Picture("logo"); logo.setImage(assetManager, "Interface/Monkey.png", true); logo.move(settings...