Game Development Reference
In-Depth Information
How to do it...
We begin by creating the controls, which are the key components of this method. This can
be done by performing the following four steps:
1. First, we create a new controls file, inventoryControls.xml , with the
<nifty-controls> tag.
2. Inside this, we first define <controlDefinition name="itemSlot">
with the following content:
<control name="droppable" backgroundColor="#fff5"
width="64px" height="64px" margin="1px"
childLayout="center"/>
3. Then similarly, we create a draggable control to be the item, and name it <con-
trolDefinition name="item" > .
4. This item contains both the draggable component and a label with the item's name:
<control name="draggable" backgroundColor="#aaaf"
width="64px" height="64px" childLayout="center"
valign="top">
<text id="#itemLabel" text="" color="#000f"
valign="center" width="100%" style="nifty-label"/>
</control>
Next, we can turn our attention to the screen itself. It can be created by performing the fol-
lowing five steps:
1. First, we make sure that the styles we want to use are loaded, and add our in-
ventoryControls.xml file is loaded with <useControls> .
2. Then, we add a <screen> element with a link to our controller file:
<screen id="inventoryScreen"
controller="gui.controller.InventoryScreenController">
3. Inside this, we need a <layer> element:
<layer id="layer0" childLayout="center"
backgroundColor="#0000">
Search WWH ::




Custom Search