Game Development Reference
In-Depth Information
How to do it...
Following the pattern from previous recipes, we'll start defining the controls, then move on
to the screen, and finally work on the controller. Adding the controls and screen will con-
sist of the following eight steps:
1. Inside a <nifty-control> tag, we define a new <controlDefinition
name="keyBindingControl"> .
2. Here, we'll add a horizontal spanning panel with some margin to the edges of its
container and enough height to contain text:
<panel childLayout="horizontal" width="80%"
height="25px" backgroundColor="#666f"
marginLeft="10px" marginRight="10px" marginTop="4px"
align="center" >
3. This panel will have three elements. The first is a label control that contains the
text for the key binding, as shown in the following code:
<control name="label" id="#command" width="150px"
text=""/>
4. Then, it will have a button to change the binding, displaying the current key:
<control name="button" id="#key" width="100px"
valign="center"/>
5. In between them, it will have a simple panel with width="*" .
6. Now, we can define another <controlDefinition
name="settingsControl"> that will contain a number of our keyBind-
ingControls .
7. This will contain a panel, and inside this, four keyBindingControls for each
moving direction. The IDs of these controls should be representative of the direc-
tion and end with a key as follows:
<control name="keyBindingControl" id="forwardKey"/>
8. The following points are needed for the screen:
◦ The ID should be settings, and controller should be
gui.controller.SettingsController
Search WWH ::




Custom Search