Hi.
[EDIT] The forum is eating my XML! Is there an explanation somewhere of how to paste XML in here? using the code tag does not seem to help… Trying with square brackets, this time …
I’ve started on Nifty GUI. I had some significant difficulties to get started, but now I think I got the idea. Atm, I’m just trying to have multiple transparent screen with buttons and labels, and move between them by clicking the buttons.
In the start screen, I have this:
[control align="center" childLayout="center" id="playAlone" label="PLAY ALONE" name="button" width="120px" textVAlign="center"]
[interact onClick="singlePlayer()"/]
[/control]
This does call the singlePlayer() method on the StartControler properly, which does this:
public void singlePlayer() {
System.out.println("singlePlayer()");
nifty.gotoScreen("singlePlayer");
}
The singlePlayer screen has it’s own controller. It seems to be created properly, as I can get it from Nifty, and set a reference to the app in it.
In the singlePlayer screen config, I have:
[panel childLayout="horizontal" height="9%" id="titleRow" style="nifty-panel-simple" width="*"]
[control childLayout="center" id="closeButton" label="X" name="button" textVAlign="center" valign="center"/]
[/panel]
And in the singlePlayer controller I have:
@NiftyEventSubscriber(id = "closeButton")
public void onCloseButtonClicked(final String id, final ButtonClickedEvent event) {
System.out.println(getClass().getSimpleName()+".onCloseButtonClicked()");
nifty.gotoScreen("start");
}
But this method does not get called. Why could that be?
If I comment out the event handler, and add an interact in the XML, pointing to this method instead:
public void onCloseButton() {
System.out.println("**************************************************"onCloseButton()");
nifty.gotoScreen("start");
}
Then the output comes, so I can see that my single player controller is connected to the screen. But then the nifty.gotoScreen(“start”); doesn’t have any effect, although the nifty.gotoScreen(“singlePlayer”); in the start screen works. Maybe the two issues are related?