@enum said:
Are you really sure that your variable doesn't change? Put a System.out. in the end of update() to proof?
PS: You might consider an enum to tag your screen states. Thats much better than using int-values.
there is a Sysout in the beginning of the update() which always prints 0.
the Sysout in the gameStart() prints correctly "request game start" so the call works correctly
How do you get the instance of your GuiState class?
Did you create your own instance and pass it to Nifty as a ScreenController for your screen (e.g. at fromXml(fileName, startScreenId, screenControllerClass)) or did you get the Nifty-created instance (that Nifty creates when starting your screen) with nifty.getScreen(screenId).getScreenController())?
This looks like a problem that is common with Nifty, that perhaps you let Nifty create its own instance (not giving it an instance in fromXml) and then created your own instance of the class (GuiState), ending in two separate instances. If that’s the case, I’m guessing you’re calling the gameStart() method on one of them and the update method is called on the other.
@Tumaini said:
How do you get the instance of your GuiState class?
Did you create your own instance and pass it to Nifty as a ScreenController for your screen (e.g. at fromXml(fileName, startScreenId, screenControllerClass)) or did you get the Nifty-created instance (that Nifty creates when starting your screen) with nifty.getScreen(screenId).getScreenController())?
This looks like a problem that is common with Nifty, that perhaps you let Nifty create its own instance (not giving it an instance in fromXml) and then created your own instance of the class (GuiState), ending in two separate instances. If that's the case, I'm guessing you're calling the gameStart() method on one of them and the update method is called on the other.
Oh god, thank you very much. The solution for the problem was to change:
[java]
nifty.fromXml("Interface/Menu.xml", "start");
[/java]
to
[java]
nifty.fromXml("Interface/Menu.xml", "start",this);
[/java]