示例#1
0
 @Override
 public void resize(int width, int height) {
   // camera.getPlayerCamera().setToOrtho(false, (Gdx.graphics.getWidth() / Gdx.graphics.getPpiX())
   // * 2, (Gdx.graphics.getHeight() / Gdx.graphics.getPpiY() )* 2 );
   // camera.getBackgroundCamera().setToOrtho(false, (Gdx.graphics.getWidth() /
   // Gdx.graphics.getPpiX()) * 2, (Gdx.graphics.getHeight() / Gdx.graphics.getPpiY())* 2 );
   // camera.getMiddlegroundCamera().setToOrtho(false, (Gdx.graphics.getWidth() /
   // Gdx.graphics.getPpiX()) , (Gdx.graphics.getHeight() / Gdx.graphics.getPpiY()) );
   camera.getHudStage().getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
   camera
       .getGameOverStage()
       .getViewport()
       .update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
 }
示例#2
0
  public GameScreen(MainWindow game, String levelName, boolean activateLights) {
    this.game = game;

    this.levelName = levelName;

    showGameOverScreen = false;

    this.activateLights = activateLights;

    Gdx.app.setLogLevel(Application.LOG_DEBUG);

    debugRenderer = new Box2DDebugRenderer();

    worldLoader = new WorldLoader(game, this);

    camera = new Cameras(game, worldLoader, game.getBatch());

    multiplexer = new InputMultiplexer();

    multiplexer.addProcessor(camera.getHudStage());
    multiplexer.addProcessor(worldLoader.getControls());

    Gdx.input.setInputProcessor(multiplexer);

    gameMiddleground = null;

    chooseBackground();
  }
示例#3
0
 @Override
 public void dispose() {
   worldLoader.dispose();
   debugRenderer.dispose();
   camera.dispose();
   game.dispose();
 }
示例#4
0
  @Override
  public void render(float delta) {
    // Reinigt Bildschirm
    Gdx.gl.glClearColor(0.9f, 0.1f, 0.1f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Aktualisiert Logik
    worldLoader.getRenderer().setView(camera.getPlayerCamera());
    worldLoader.updateWorld(delta);

    // Rendert alle Objeckte innerhalb des batchs
    game.getBatch().begin();
    game.getBatch().setProjectionMatrix(camera.getBackgroundCamera().combined);
    game.getBatch()
        .draw(
            gameBackground,
            -15,
            -10,
            gameBackground.getWidth() / 40,
            gameBackground.getHeight() / 30);
    game.getBatch()
        .draw(
            gameBackground,
            -15 + gameBackground.getWidth() / 40,
            -10,
            gameBackground.getWidth() / 40,
            gameBackground.getHeight() / 30,
            0,
            0,
            gameBackground.getWidth(),
            gameBackground.getHeight(),
            true,
            false);
    if (gameMiddleground != null) {
      game.getBatch().setProjectionMatrix(camera.getMiddlegroundCamera().combined);
      game.getBatch()
          .draw(
              gameMiddleground,
              -15,
              -10,
              gameBackground.getWidth() / 40,
              gameBackground.getHeight() / 30);
      game.getBatch()
          .draw(
              gameMiddleground,
              -15 + gameBackground.getWidth() / 40,
              -10f,
              gameBackground.getWidth() / 40,
              gameBackground.getHeight() / 30,
              0,
              0,
              gameBackground.getWidth(),
              gameBackground.getHeight(),
              true,
              false);
    }

    game.getBatch().end();

    camera.update(delta);
    // Rendert tmx map
    game.getBatch().setProjectionMatrix(camera.getPlayerCamera().combined);
    worldLoader.renderMap(game.getBatch());

    // Rendert Physik-Debug Texturen
    // debugRenderer.render(worldLoader.getWorld(), camera.getPlayerCamera().combined);

    if (showGameOverScreen == true) {
      // camera.getGameOverStage().getBatch().setColor(Color.RED);
      game.getBatch().begin();
      game.getBatch().setColor(0.9f, 0.1f, 0.1f, 0.6f);
      /*
      game.getBatch().draw(game.getAssets().getWhiteColor(),0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
      */
      game.getBatch().end();
      camera.getGameOverStage().draw();

    } else if (showMenuScreen == true) {
      camera.getMenuStage().draw();
    } else if (showGameEndScreen == true) {
      camera.getGameEndStage().draw();
    } else {
      camera.render(game.getBatch());
    }
  }