Game Development Reference
In-Depth Information
How to do it...
Before we work on the screen, we should define a new reusable Nifty control to contain the
character information of the character the player is talking to; perform the following steps
to do this:
1. Create a new file called
characterDialogControls.xml
with the
<nifty-controls>
tag, and inside it, create a new
<controlDefinition
name="characterControl">
class.
2. The layout for this is fairly simple; it needs one
<panel>
element that contains
another
<panel>
for the character image and a
<control name="label">
element for the name.
Now, let's build the dialog screen. We do this by performing the following nine steps:
1. Create a new file called
dialogScreen.xml
and load
nifty-default-
styles
and
nifty-default-controls
. It should also load the
charac-
terDialogControls.xml
file. We can also include
optionsMenu
from the
previous recipe.
2. The first element we need is a
<screen>
element:
<screen id="dialogScreen"
controller="gui.controller.DialogScreenController">
3. Inside this, we define a
<layer>
element:
<layer id="layer0" childLayout="center"
backgroundColor="#0000">
4. Inside the
<layer>
element, we define
<panel>
, which will contain the rest of
our layout:
<panel id="dialogPanel" childLayout="vertical"
visible="false">
5. We'll add a short fade effect to this panel as well:
<effect>
<onShow name="fade" start="#00" end="#ff"
length="200" inherit="true"/>