Game Development Reference
In-Depth Information
How it works...
Getting the layout exactly as we want can be tricky sometimes, but in general, it's import-
ant to know that Nifty really likes the width and height to be defined.
Using the ListBox here gives us a lot for free since it handles a dynamic number of options,
and callbacks to the code are easily handled with the
listener
method. By default, it has
scrollbars and handles multiple selection, which is why we explicitly defined it to be
se-
lection="Single"
and used
vertical="off"
and
horizontal="off"
to turn
off the scrollbars. It also supports item selection by using the up, down, and
Enter
keys.
The listener method in the controller can be referred to as anything; what Nifty looks for is
the annotation and the method's parameters. From here, we can call the next
DialogNode
or other code based on the player's choices.