Class 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
    • 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.