Class GameTime

java.lang.Object
com.csse3200.game.services.GameTime

public class GameTime extends Object
Controls the game time
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the GameTime class.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Get the time since the last frame in seconds, scaled by time scale
    float
    Get the raw time since the last frame in seconds
    long
    Get the time since the game started in milliseconds
    long
    getTimeSince(long lastTime)
    Get the time since the last time in milliseconds
    void
    setTimeScale(float timeScale)
    Set the speed of time passing.

    Methods inherited from class java.lang.Object

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

    • GameTime

      public GameTime()
      Constructor for the GameTime class.
  • Method Details

    • setTimeScale

      public void setTimeScale(float timeScale)
      Set the speed of time passing. This affects getDeltaTime()
      Parameters:
      timeScale - Time scale, where normal speed is 1.0, no time passing is 0.0
    • getDeltaTime

      public float getDeltaTime()
      Get the time since the last frame in seconds, scaled by time scale
      Returns:
      time passed since the last frame in seconds, scaled by time scale.
    • getRawDeltaTime

      public float getRawDeltaTime()
      Get the raw time since the last frame in seconds
      Returns:
      time passed since the last frame in seconds, not affected by time scale.
    • getTime

      public long getTime()
      Get the time since the game started in milliseconds
      Returns:
      time passed since the game started in milliseconds
    • getTimeSince

      public long getTimeSince(long lastTime)
      Get the time since the last time in milliseconds
      Parameters:
      lastTime - the time to get the time since
      Returns:
      the time since the last time