Adding multiple windows in LibGDX?

元气小坏坏 提交于 2019-12-06 02:52:17
asherbar

Basically, you can run each window in a separate process (use the answer here to see how to implement JavaProcess which is used below):

public class Tiles {
   public static void main(String[] args) {
      LwjglApplicationConfiguration configForTiles = new LwjglApplicationConfiguration();
      TilePresets tilesWindow = new TilePresets();
      LwjglApplication tiles = new LwjglApplication(tilesWindow, configForTiles);
   }
}

Wrapper.java is the main entry point. It's where launching both windows occurs:

public class Wrapper {
   public static void main(String[] args) {
      // Launch mapWindow regularly 
      LwjglApplicationConfiguration configForMap = new LwjglApplicationConfiguration();
      MapMaker mapWindow = new MapMaker();
      LwjglApplication map = new LwjglApplication(mapWindow, configForMap);

      try {
         int res = JavaProcess.exec(Tiles.class); // Where the second window is shown
      } catch (IOException e) {
         e.printStackTrace();
      } catch (InterruptedException e) {
         e.printStackTrace();
      }
   }
}

Credit alert! I had a similar question and I found this solution somewhere, but I can't remember where. I'll post the source here when I find it.

Edit: Credit goes to the person from which I got the idea for this solution.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!