Stopping a game

In this tutorial ( there is the quitGame() method that calls app.stop(); When I run this, it just prints out a ton of WARNING notices to the console, but doesn’t stop the game.

gist:1329006 · GitHub

Anyone have any ideas?



app.stop() does work. What warnings do you get? Maybe its due to your ruby setup?

Here’s a link to the warnings I’m getting.

Sadly I couldn’t get it running with ruby :frowning: So I’m compiling the .java into a .class, and running that… I’m hoping that figuring this out will teach me what I need to know to run it in ruby though.

So does your ScreenController implement the right function, do you supply the right screen controller when creating the nifty object and do you specify the right screen controller class in the XML file? Seems like it cannot find the method.

Yeah, I supply all the stuff. I added a System.out.println("nn CALLING quitGame() nn); and it prints that to the console right before throwing all those warning. My startGame() method that does the nifty.gotoScreen() works fine, no errors, and it goes to the hud screen.

then try/catch any errors that might come after that. Nifty doesn’t pipe them to the output.

I tried this and got “Error: null”

[java]public void quitGame() {

System.out.println(“nn quitGame callednn”);

try {


} catch (Exception e) {

System.out.println("nn Error: " + e.getMessage());



e.printStackTrace() is more insightful, probably your app variable is null.

hmm… Yeah, it looks like the same trace as those warnings.


at StartScreenController.quitGame(

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(

at sun.reflect.DelegatingMethodAccessorImpl.invoke(

at java.lang.reflect.Method.invoke(

at de.lessvoid.nifty.NiftyMethodInvoker.callMethod(

at de.lessvoid.nifty.NiftyMethodInvoker.performInvoke(

at de.lessvoid.nifty.Nifty$DelayedMethodInvoke.perform(

at de.lessvoid.nifty.Nifty.invokeMethods(

at de.lessvoid.nifty.Nifty.handleDynamicElements(

at de.lessvoid.nifty.Nifty.access$1400(

at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processEvent(

at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processMouseEvent(

at com.jme3.niftygui.InputSystemJme.onMouseButtonEventQueued(

at com.jme3.niftygui.InputSystemJme.forwardEvents(

at de.lessvoid.nifty.Nifty.update(

at com.jme3.niftygui.InputSystemJme.endInput(

at com.jme3.input.InputManager.processQueue(

at com.jme3.input.InputManager.update(



at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(



Now, I’m not passing the app into it. The example just shows creating a new instance of the controller, and using that as the third parameter to

[java]nifty.fromXml(“Interface/screen.xml”, “start”, new StartScreenController());


That code is inside my simpleInitApp, so should I be passing “this”? like

[java]nifty.fromXml(“Interface/screen.xml”, “start”, new StartScreenController(this));


Thats not the same as the warnings ^^ Yeah, your app variable definitely is null, what you said should work.

1 Like

effing sweet! I had to change the constructor to take an Application instance instead of a String like in the example, so I hope that doesn’t hinder me later, but other than that, it works! Thanks!!


Btw the ScreenController in the example extends AbstractAppState, there you have access to the app variable by default.