Class Timer

  • All Implemented Interfaces:
    Updatable

    public class Timer
    extends java.lang.Object
    implements Updatable
    Utility class for time-based behavior. Callback actions can be attached to the timer, and will then be automatically called once the timer has been completed.
    • Constructor Summary

      Constructors 
      Constructor Description
      Timer​(float duration)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void attach​(java.lang.Runnable action)  
      float getDuration()  
      float getRatio()  
      float getTime()  
      static Timer indefinite()
      Returns a timer that will run indefinitely and will never complete.
      boolean isCompleted()  
      void reset()  
      void reset​(float duration)  
      void update​(float deltaTime)
      Updates this object for the current frame.
      • Methods inherited from class java.lang.Object

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

      • Timer

        public Timer​(float duration)
    • Method Detail

      • update

        public void update​(float deltaTime)
        Description copied from interface: Updatable
        Updates this object for the current frame.
        Specified by:
        update in interface Updatable
        Parameters:
        deltaTime - Elapsed time since the last frame, in seconds.
      • getTime

        public float getTime()
      • getDuration

        public float getDuration()
      • isCompleted

        public boolean isCompleted()
      • getRatio

        public float getRatio()
      • reset

        public void reset()
      • reset

        public void reset​(float duration)
      • attach

        public void attach​(java.lang.Runnable action)
      • indefinite

        public static Timer indefinite()
        Returns a timer that will run indefinitely and will never complete.