Hi, I m trying to create pause menu popup but when the popup shows up i m not getting interaction, meaning this method is not called
public void unpause() {
log.log(Level.SEVERE, " unpause");
nifty.closePopup(pausePopup.getId());
}
Here is the GameRunningAppState class
public class GameRunningAppState extends BaseAppState implements ScreenController, Controller {
protected static Logger log = Logger.getLogger(GameRunningAppState.class.getName());
private Main game;
private Nifty nifty;
private Element pausePopup;
@Override
protected void initialize(Application app) {
log.log(Level.SEVERE, " initialize");
this.game = (Main) app;
nifty = this.game.getNifty();
pausePopup = nifty.createPopup("pause");
}
@Override
protected void cleanup(Application app) {
log.log(Level.SEVERE, " cleanup");
}
@Override
protected void onEnable() {
}
@Override
protected void onDisable() {
}
public void bind(Nifty nifty, Screen screen) {
log.log(Level.SEVERE, " bind");
}
public void onStartScreen() {
}
public void onEndScreen() {
}
/**
* custom methods
*/
public void quitGame() {
log.log(Level.SEVERE, " quitGame");
game.stop();
}
public void gotoScreen(String screenId) {
log.log(Level.SEVERE, " gotoScreen");
//Proof that game object is in app state
game.getNifty().gotoScreen(screenId);
}
public void pause() {
nifty.showPopup(nifty.getCurrentScreen(), pausePopup.getId(), null);
}
public void unpause() {
log.log(Level.SEVERE, " unpause");
nifty.closePopup(pausePopup.getId());
}
public void bind(Nifty nifty, Screen screen, Element element, Properties parameter, Attributes controlDefinitionAttributes) {
}
public void init(Properties parameter, Attributes controlDefinitionAttributes) {
}
public void onFocus(boolean getFocus) {
}
public boolean inputEvent(NiftyInputEvent inputEvent) {
return true;
}
}
and nifty xml
<?xml version="1.0" encoding="UTF-8"?>
<nifty xmlns="http://nifty-gui.sourceforge.net/nifty-1.3.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd">
<useStyles filename="nifty-default-styles.xml" />
<useControls filename="nifty-default-controls.xml" />
<screen id="hud" controller="com.me.GameRunningAppState">
<!--<layer id="background" childLayout="center">
<image filename="Interface/hud-frame.png"></image>
</layer>-->
<layer id="foreground" childLayout="horizontal">
<panel id="panel_left" width="80%" height="100%" childLayout="vertical" ></panel>
<panel id="panel_right" width="20%" height="100%" childLayout="vertical">
<panel id="panel_top_right2" width="100%" height="15%" childLayout="center">
<image filename="Interface/pause-button.png" valign="center" align="center" height="50%" width="30%" >
<interact onClick="pause()"/>
</image>
</panel>
<panel id="panel_bot_right" width="100%" height="70%" valign="center" ></panel>
</panel>
</layer>
</screen>
<popup id="pause" childLayout="center" backgroundColor="#000a" controller="com.me.GameRunningAppState">
<panel style="nifty-panel-red" childLayout="center" padding="18px,28px,40px,16px" width="40%" height="30%" align="center" valign="center">
<panel id="continue" width="100%" height="40%" childLayout="center">
<image filename="Interface/pause-button.png" valign="center" align="center" height="70%" width="30%" >
<interact onClick="unpause()"/>
</image>
</panel>
</panel>
</popup>
</nifty>