Game Development Reference
In-Depth Information
How it works...
Nifty was initialized inside
AppState
to offset the code from the main application and
make it more modular. This also made it easier to add some more general functionalities re-
lated to controlling the GUI.
Every nifty
Controller
class must implement the
ScreenController
interface for
Nifty to be able to find it. Since some functions will be shared across the screens, we cre-
ated an abstract class called
NiftyController
to avoid duplicating the code. Apart
from handling the generic Options menu, it was also given access to the application itself.
The link between the XML file and the
Controller
class doesn't need to be specified
beyond providing the qualified name of the controller in the screen. Likewise, Nifty will
find methods automatically using the name provided in the
interact
tag of
But-
tonControl
.
The
<panel>
elements are versatile objects that can be used for many parts of the layout
and can contain most other types of layout items.
It's OK to contain several
<controlDefinition>
elements within a
<nifty-con-
trols>
tag.