How can I stop the a jMonkeyEngine game?

356 views Asked by At

I want to quit the game, if 2 values are higher than 3. I want to put in in here:

        if(player.getWorldTranslation().y > 3){
            if(player.getWorldTranslation().z > 3){
                 
            }

I guess its in the documentation, but I still couldĀ“nt find any answer after 10minutes searching. Thanks for helping!

2

There are 2 answers

0
Luke Melaia On

Here's a link to quitting the game. You could also use System.exit(int). Either way it works.

1
Luis Correa On

I think, the best(if you need to stop the game and not the program):

static Main app;//Put the app variable global and static
...

public static void main(String[] args) {
   app = new Main();
   app.start();
}
...

if(player.getWorldTranslation().y > 3){
    if(player.getWorldTranslation().z > 3){
        app.Stop(1);
        //System.exit(1);//if you need close the entire program;
    }