Game Development Reference
In-Depth Information
There's moreā¦
Let's say we would like to be able to show messages in a window, either when clicking the
message in the queue, or any time. In that case, we can use Nifty's window control.
We can define a new
controlDefinition
in our
gameMessageControls.xml
file and call it
messageWindow
. Inside this, we'll add
<control name="window">
,
inside which we can add any content we'd like. For now, we can settle with
<control
name="label">
for text content and a short fade effect when showing or hiding the
window.
Then, we can copy the
addMessage
method to
MainScreenController
, and in-
stead of having
ControlBuilder
make
gameMessage
, we can tell it to build a
mes-
sageWindow
window instead.
We don't need an
interactOnClick
element, as the window can be closed by default.
Instead, we can use it to set the title of the window:
set("title", "Window"+windowIndex);
Windows are also draggable by default, but the parent element must have
childLay-
out="absolute"
for it to work, as it lets the element decide its position itself.