Game Development Reference
In-Depth Information
of the screen. We will use an
imageSizePulsate
effect to animate this and
have it fade in as well, as shown in the following code:
<effect>
<onShow name="fade" start="#00" end="#ff"
length="1000"/>
<onShow name="imageSizePulsate" startSize="100%"
endSize="50%" pulsator="SinusPulsator"
activated="true" timeType="infinite"/>
</effect>
9. Optionally, we can also add another
<layer>
tag beside the previous one that
will contain the
options
control from the previous recipe.
Now, we have a complete XML. Let's have a look at the controller for this. We will create
it by performing the following seven steps:
1. We begin by creating a new class called
LoadingScreenController
that
extends the
NiftyController
class we created in the previous recipe.
2. We define two strings,
loadingText
and
loadingScreen
, and setters for
these as well.
3. Next, we override the
onStartScreen()
method and add the following three
lines to it:
screen.findNiftyControl("caption",
Label.class).setText(loadingText);
screen.findElementByName("centralPanel").getRenderer(ImageRenderer.class).setImage(nifty.createImage(loadingScreen,
true));
screen.findElementByName("loadingPanel").setVisible(true);
4. The controller is now done. However, there are some more things we need to do
before we can look at it.
5. First, we need to add the screen to Nifty. If we have the
NiftyAppState
meth-
od from the previous recipe, we should add the following line just after the
nifty.fromXml
call:
nifty.addXml("Interface/Screens/loadingScreen.xml");
6. We can also add a
convenience
class to access
nifty.gotoScreen()
.