Class Timer


  • public class Timer
    extends java.lang.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
    • Constructor Summary

      Constructors 
      Constructor Description
      Timer()
      Constructs a timer.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float getTime()  
      boolean isPaused()  
      void pause()
      Pause the timer.
      void reset()
      Reset the timer.
      void resume()
      Resume the timer.
      void set​(float newTime)
      Set the time of this timer
      static void tick()
      Get the next time update from the system's hires timer.
      java.lang.String toString()
      Debug output.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Timer

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

      • 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:
        resume()
      • reset

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

        public void resume()
        Resume the timer.
        See Also:
        pause()
      • 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 java.lang.String toString()
        Debug output.
        Overrides:
        toString in class java.lang.Object