Class Timer

java.lang.Object
org.lwjgl.util.Timer

public class Timer extends Object
A hires timer. This measures time in seconds as floating point values. All Timers created are updated simultaneously by calling the static method tick(). This ensures that within a single iteration of a game loop that all timers are updated consistently with each other.
Version:
$Revision$ $Id$
Author:
cix_foo <cix_foo@users.sourceforge.net>
  • Constructor Details

    • Timer

      public Timer()
      Constructs a timer. The timer will be reset to 0.0 and resumed immediately.
  • Method Details

    • getTime

      public float getTime()
      Returns:
      the time in seconds, as a float
    • isPaused

      public boolean isPaused()
      Returns:
      whether this timer is paused
    • pause

      public void pause()
      Pause the timer. Whilst paused the time will not change for this timer when tick() is called.
      See Also:
    • reset

      public void reset()
      Reset the timer. Equivalent to set(0.0f);
      See Also:
    • resume

      public void resume()
      Resume the timer.
      See Also:
    • set

      public void set(float newTime)
      Set the time of this timer
      Parameters:
      newTime - the new time, in seconds
    • tick

      public static void tick()
      Get the next time update from the system's hires timer. This method should be called once per main loop iteration; all timers are updated simultaneously from it.
    • toString

      public String toString()
      Debug output.
      Overrides:
      toString in class Object