To start things off, let's begin with a simple recipe that will provide us with the basics of setting up the application to use Nifty GUI and tell us how to manage the options menu. An options menu is usually found in games; it acts as a link between different screens. For this reason, it's suitable to create it using the control pattern so it can be easily handled across screens.
We'll initialize Nifty GUI inside AppState
to offset it from the main application code and then access the application from Nifty and control Nifty through code.
Let's look at how to initialize Nifty in an application. We start off by defining a new AppState
to handle our Nifty functions. We can call it NiftyAppState
and have it extend AbstractAppState
.
In the initialize
method, we need to create the Nifty display with the following line of code, giving Nifty access to various functionalities within the application and telling it to render o
in the GUI view...