@Override
  protected void updateExample(final ReadOnlyTimer timer) {
    if (allowClicks && zoom) {
      if (index > COUNT - 1) {
        index = COUNT - 1;
      } else if (index < 0) {
        index = 0;
      }
      final int currentTile = MathUtils.floor(index);
      final float fract = index - currentTile;

      if (firstTile != currentTile - 1) {
        // update the textures on the tiles
        firstTile = MathUtils.floor(index - 1);

        for (int i = 0; i < views.length; i++) {
          if (firstTile + i >= 0 && firstTile + i < COUNT) {
            views[i].removeAllComponents();
            views[i].add(srcs[firstTile + i]);
            views[i].updateMinimumSizeFromContents();
            views[i].layout();
            views[i].setVisible(true);
          } else {
            views[i].setVisible(false);
          }
        }
      }

      // update the positions of the tiles.
      final int y = (_canvas.getCanvasRenderer().getCamera().getHeight() / 2) - (hside / 2);
      for (int i = 0; i < views.length; i++) {
        final float x = (i - fract) * (wside + padding);
        views[i].setHudXY(Math.round(x), y);
      }

      // check for and apply movement
      index += timer.getTimePerFrame() * speed;
    }

    // update hud input
    hud.updateGeometricState(timer.getTimePerFrame());
  }
예제 #2
0
 @Override
 protected void updateExample(final ReadOnlyTimer timer) {
   counter += timer.getTimePerFrame();
   frames++;
   if (counter > 1) {
     final double fps = (frames / counter);
     counter = 0;
     frames = 0;
     System.out.printf("%7.1f FPS\n", fps);
   }
 }
 @Override
 protected void updateLogicalLayer(final ReadOnlyTimer timer) {
   hud.getLogicalLayer().checkTriggers(timer.getTimePerFrame());
 }