I’m working on this tutorial here
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:nifty_gui_java_interaction
With the initialize method here, when does that get called in the app? After the constructor is called? It only gets called once, right? The reason I ask is because I’m writing all this stuff in Ruby, and “initialize” is a reserved method, so I’m trying to figure a way around using this method. I can call the initialize method, I just can’t define it as it shows in the example.
Thanks,
~Jeremy
Yes, the initialize method gets called after the constructor and only once. You can have a look at the AppStateManager class for the exact procedure
hmm… Ok…
So, the screen shows up, and there’s no errors, but clicking on the buttons just changes the color of them, and logs some stuff. I’m not seeing the quitGame() or startGame() methods being called… Also, my main title text says “${CALL.getPlayerName()}'s Cool Game” instead of “Jeremy’s Cool Game”…
Is there anything in particular I should look for that the internals call to make all the gui interactions happen?
Thanks for the help!
~Jeremy
I haven’t used Nifty at all so I can’t help you with that unfortunately…
damn Alright, I shall just hack away until something works!
sbook said:
Yes, the initialize method gets called after the constructor and only once. You can have a look at the AppStateManager class for the exact procedure
Up until yesterday, the above statement was not necessarily true. initialize() could be called three times a frame is isInitialized() returned false.
...I fixed that among other things. :)
And now AppStateManager has a very specific life cycle for its app states. At least in SVN (life cycle spelled out in the javadoc there too).
ok, so I need to pull the latest nightly build then?
I don’t know if nightlies work like they did before or not. But you can check.
As long as initialize sets initialized to true then initialize will only be called once. I fixed some things to take that issue out of the users’ hands because it bit me a few times, and seems to bite everyone at least once.
Ah. I see. Yeah, I plugged the newest in, and things seem to work except my original issue. My “startGame(hud)” or “quitGame()” never get called…
Right now I’m just logging to the console when it does. I’m using the nifty.fromXml(“screen.xml”, “start”, new MyScreenController())
So that seems like a nifty setup problem or something.
Yeah. I’m still not all that familiar with it. It’s so much easier when errors show up, but I see buttons, and everything…
Do you think this is still valid with the latest update?
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:nifty_gui_java_interaction
I don’t know. I got nifty working fine for me and then I never touch it. Others may be able to help better and it may get more eyes in a separate topic.