2016-12-18 52 views
2

我想退出遊戲,如果2點的值大於3。我希望把這裏:如何停止jMonkeyEngine遊戲?

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

我猜測它的文檔中,但我仍然could' nt在10分鐘搜索後找到任何答案。 感謝您的幫助!

+0

'System.exit(1);' – Alex

+1

調用'停止()'從你的類,它擴展來自'Application'; https://jmonkeyengine.github.io/wiki/jme3/intermediate/simpleapplication.html – trooper

回答

0

Here's退出遊戲的鏈接。您也可以使用System.exit(int)。無論哪種方式,它的作品。

1

我認爲,最好的(如果你需要停止比賽,而不是程序):

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; 
    } 
+0

應該是'app.stop(1);'。 –