I have a nifty main menu. Whe the button “Campagin” is pressed, I call nifty.exit() to remove the main menu and enable the flycam. Nifty menu disappears, but mouse keeps being shown and when I move it, the scene moves, but mouse isn’t trapped in the middle of the screen…
My main menu appstate:
[java]
public class StartScreenState extends AbstractAppState implements ScreenController{
private Nifty nifty;
private Screen screen;
private MWApp app;
NiftyJmeDisplay display;
public StartScreenState(NiftyJmeDisplay display){
super();
this.display = display;
}
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app = (MWApp)app;
//TODO: initialize your AppState, e.g. attach spatials to rootNode
//this is called on the OpenGL thread after the AppState has been attached
}
@Override
public void update(float tpf) {
//TODO: implement behavior during runtime
}
@Override
public void cleanup() {
super.cleanup();
//TODO: clean up what you initialized in the initialize method,
//e.g. remove all spatials from rootNode
//this is called on the OpenGL thread after the AppState has been detached
}
public void bind(Nifty nifty, Screen screen) {
this.nifty = nifty;
this.screen = screen;
}
public void onStartScreen() {
//throw new UnsupportedOperationException("Not supported yet.");
}
public void onEndScreen() {
//throw new UnsupportedOperationException("Not supported yet.");
}
public void quit(){
app.stop();
System.exit(0);
}
public void settings(){
//TODO Switch to settings screen
System.out.println("No settings yet...");
}
public void campagin(){
//TODO
System.out.println("Campagin clicked.");
nifty.exit();
app.getFlyCam().setEnabled(true);
}
}
[/java]