Game Development Reference
In-Depth Information
How to do it...
Just as before, we begin by defining a control that will host the console. It can be done by
performing the following four steps:
1. Inside the <nifty-controls> tags, we add a new <controlDefinition
name="consoleControl"> class.
2. Then, we add a small console, aligning it with the bottom of the screen:
<control id="console" name="nifty-console" lines="10"
width="100%" valign="bottom" backgroundColor="#6874"
visible="true">
3. To spice up the simple console, we give it a Move effect when it's being shown or
hidden:
<effect>
<onShow name="move" mode="fromOffset" offsetY="100"
length="300" inherit="true"/>
<onHide name="move" mode="toOffset" offsetY="100"
length="200" inherit="true"/>
</effect>
4. In mainScreen.xml , we add controlDefinition inside a new layer:
<layer id="consoleLayer" childLayout="center"
backgroundColor="#0000">
<control name="consoleControl"/>
</layer>
That's it for XML hacking. Now, we can turn our attention to the NiftyController
class from the Initializing Nifty and managing an options menu recipe and add a console to
handle to it. This can be done by performing the following 10 steps:
1. We need to add a new field, Console console , and bind it using the following
code:
nifty.getScreen("main").findNiftyControl("console",
Console.class);
Search WWH ::




Custom Search