Hi!
[java]
<control width=“25%” name=“button” label=“Ok” align=“center” color="#000f">
<interact onClick=“enter()”/>
</control>
[/java]
That is the way I want to make my button start the game.
The ScreenController is set:
[java]
<screen id=“NameScreen” controller=“mygame.Game”>
[/java]
And in the Game class, there is a method called:
[java]
public void enter()
[/java]
It initializes the keys and so on.
But nothing happens when I click that button.
I already tried to solve the problem by usen onRelease but nothing happened.
I did everything step by step like in the tutorials.
The only thing that seems to be unusual is that the button stays “being pressed”
So after I released it it doesn’t have it’s normal color.
I don’t really know how to explain that (fighting with my english), but when I clicked it once, and realeased it, the button still looks like it would still be pressed…
Before:
http://www7.pic-upload.de/04.07.12/u5voz85mmlzd.png
After releasing:
Thanks for the tipp, it’s working now, BUT: how do I remove that nifty GUI?
I tried the exit() method and to remove the screen, but as I read here:
http://hub.jmonkeyengine.org/groups/gui/forum/topic/nifty-seems-to-ignore-new-screen-controllers/?topic_page=2&num=15
That caused troubles before trying to switch screens.
The exit() method or
[java]
guiViewPort.removeProcessor(niftyDisplay);[/java]
does not work.
SOLVED:
registered the ScreenController before loading xml file.
[java]
nifty.registerScreenController(this);
nifty.fromXml(“Interface/NameScreen.xml”, “NameScreen”);
[/java]
Did you register the screen controller with nifty?
Has your screen controller implemented the screen controller interface?
Do you get any warnings etc in the logging?
That looks right