# Integrating Nifty GUI: Overlay

1. Nifty GUI XML Layout
2. Nifty GUI Overlay or Nifty GUI Projection
3. Interact with the GUI from Java

Define a key (for example escape) that switches the GUI on and off. You can either overlay the running game with the GUI (you will most likely pause the game then), or even project it as a texture onto a mesh texture (but then you cannot click to select).

On this page, we look at the overlay variant (more commonly used).

## Sample Code

## Overlaying the User Interface Over the Screen

This code shows you how to overlay anything on the screen with the GUI. This is the most common usecase.

    NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(
        assetManager, inputManager, audioRenderer, guiViewPort);
    Nifty nifty = niftyDisplay.getNifty();

    // init Nifty start screen
    nifty.fromXml("Interface/helloworld.xml", "start");

    // attach the Nifty display to the gui view port as a processor
    guiViewPort.addProcessor(niftyDisplay);
    // disable the fly cam
    flyCam.setDragToRotate(true);

1. Nifty GUI XML Layout
2. Nifty GUI Overlay or Nifty GUI Projection
3. Interact with the GUI from Java

documentation, gui

view online version