I write a basic game with nifty gui by seeing nifty tutorial but I can’t get a int value from MyStartScreen. My xml screen part is:
<screen id="finish" controller="StormySpace.MyStartScreen">
<layer id="foreground" childLayout="vertical" >
<panel id="top" width="100%" height="40%" childLayout="center">
<text text="GAME OVER" font="Interface/Fonts/Purisa.fnt" valign="bottom" width="100%" height="100%" wrap="true"/>
</panel>
<panel id="mid" width="100%" height="30%" childLayout="center">
<text text="Your Score: ${CALL.scoreGame()}" font="Interface/Fonts/Purisa.fnt" valign="top" width="100%" height="100%" wrap="true"/>
</panel>
<panel id="bottom" widht="100%" height="30%" align="center" childLayout="horizontal">
<control name="button" label="Quit" id="QuitButton2" align="center" valign="center" visibleToMouse="true" >
<interact onClick="quitGame()"/>
</control>
</panel>
</layer>
</screen>
and MyStartScreen.java part:
int score;
public void finishGame(int score)
{
this.score = score;
System.out.println(this.score);
nifty.gotoScreen("finish");
}
public int scoreGame()
{
System.out.println(score);
return score;
}
Everything is fine but just game never run scoreGame() methode. I see “Your Score: 0” on screen. I add println methods for controling and just first is running. Anybody help me?