Time for action – loading icons into the GUI

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.

  1. Save images for the user interface in your project's Interface directory.
  2. The following code sample loads a GUI element named frame.png and attaches it to the rootNode:
    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); ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.