Exemplo n.º 1
0
    @Override
    public void render() {
      Gdx.gl.glClearColor(1, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
      sharedSpriteBatch
          .getProjectionMatrix()
          .setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
      sharedSpriteBatch.begin();
      sharedSpriteBatch.draw(
          sharedTexture, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY() - 1);
      sharedSpriteBatch.end();

      if (Gdx.input.justTouched()) {
        Lwjgl3Application app = (Lwjgl3Application) Gdx.app;
        Lwjgl3WindowConfiguration config = new Lwjgl3WindowConfiguration();
        DisplayMode mode = Gdx.graphics.getDisplayMode();
        config.setWindowPosition(
            MathUtils.random(0, mode.width - 640), MathUtils.random(0, mode.height - 480));
        config.setTitle("Child window");
        Class clazz = childWindowClasses[MathUtils.random(0, childWindowClasses.length - 1)];
        ApplicationListener listener = null;
        try {
          listener = (ApplicationListener) clazz.newInstance();
        } catch (Throwable t) {
          new GdxRuntimeException("Couldn't instantiate app listener", t);
        }
        Lwjgl3Window window = app.newWindow(listener, config);
      }
    }