Exemplo n.º 1
0
  @Override
  public void render() {
    long now = System.nanoTime();
    update();
    clearScreen();

    //		tiledMapHelper.getCamera().position.x = PIXELS_PER_METER * tokine.body.getPosition().x;
    camera.position.x = Constants.PIXELS_PER_METER * tokine.body.getPosition().x;

    handleScreenBoundaries();

    tiledMapHelper.getCamera().update();
    tiledMapHelper.render();

    batch.begin();
    tokine.render(batch, camera);
    batch.end();

    /** Draw this last, so we can see the collision boundaries on top of the sprites and map. */
    camera.update();
    debugRenderer.render(
        world,
        tiledMapHelper
            .getCamera()
            .combined
            .scale(
                Constants.PIXELS_PER_METER,
                Constants.PIXELS_PER_METER,
                Constants.PIXELS_PER_METER));

    if (now - lastRender < 30000000) { // 30 ms, ~33FPS
      try {
        Thread.sleep(30 - (now - lastRender) / 1000000);
      } catch (InterruptedException e) {
      }
    }
    lastRender = now;
  }