Class Timer

java.lang.Object
nl.colorize.multimedialib.scene.Timer
All Implemented Interfaces:
Updatable

public class Timer extends Object implements Updatable
Utility class for time-based behavior. A timer consists of a position and a duration. The position is moved during every frame update, until the duration has been reached.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Timer(float duration)
    Creates a new timer with the specified duration in seconds.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    end()
     
    static Timer
    ended(float duration)
    Factory method that creates a timer which starts in the ended state, and needs to be reset before it can be used.
    float
     
    float
     
    float
     
    float
     
    static Timer
    Factory method that creates a timer which will never reach his duration.
    boolean
     
    static Timer
    Factory method that creates a no-op timer with a zero duration.
    void
     
     
    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, wait, wait, wait
  • Constructor Details

    • Timer

      public Timer(float duration)
      Creates a new timer with the specified duration in seconds.
  • Method Details

    • update

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

      public float getTime()
    • getTimeRemaining

      public float getTimeRemaining()
    • getDuration

      public float getDuration()
    • isCompleted

      public boolean isCompleted()
    • getRatio

      public float getRatio()
    • reset

      public void reset()
    • end

      public void end()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • none

      public static Timer none()
      Factory method that creates a no-op timer with a zero duration.
    • infinite

      public static Timer infinite()
      Factory method that creates a timer which will never reach his duration.
    • ended

      public static Timer ended(float duration)
      Factory method that creates a timer which starts in the ended state, and needs to be reset before it can be used.