Package jme3utilities

Class TimeOfDay

java.lang.Object
com.jme3.app.state.AbstractAppState
jme3utilities.NamedAppState
jme3utilities.TimeOfDay
All Implemented Interfaces:
com.jme3.app.state.AppState

public class TimeOfDay extends NamedAppState
A named appstate to simulate the time of day in a game.

Each instance is enabled at creation.

  • Field Details

    • hoursPerDay

      public static final int hoursPerDay
      duration of a full day (in hours)
      See Also:
    • minutesPerHour

      public static final int minutesPerHour
      number of minutes in an hour
      See Also:
    • secondsPerMinute

      public static final int secondsPerMinute
      number of seconds in a minute - declared early due to a dependency
      See Also:
    • secondsPerHour

      public static final int secondsPerHour
      number of seconds in an hour - declared early due to a dependency
      See Also:
    • secondsPerDay

      public static final int secondsPerDay
      number of seconds in a day
      See Also:
  • Constructor Details

    • TimeOfDay

      public TimeOfDay(float startHour)
      Instantiate a new enabled, uninitialized simulation clock, specifying the start time.
      Parameters:
      startHour - hours since midnight (<24, ≥0)
  • Method Details

    • getRate

      public float getRate()
      Read the simulation rate.
      Returns:
      the simulation rate relative to real time (may be negative)
    • hour

      public float hour()
      Determine the simulated time of day in hours.
      Returns:
      hours since midnight (<24, ≥0)
    • second

      public int second()
      Determine the simulated time of day in whole seconds.
      Returns:
      seconds since midnight (<86400, ≥0)
    • setHour

      public void setHour(float newHour)
      Alter the simulation time.
      Parameters:
      newHour - hours since midnight (<24, ≥0)
    • setRate

      public void setRate(float newRate)
      Alter the simulation rate.
      Parameters:
      newRate - simulation rate relative to real time (may be negative)
    • toString

      public String toString()
      Represent this time of day as a text string.
      Overrides:
      toString in class NamedAppState
      Returns:
      descriptive string of text (not null)
    • update

      public void update(float interval)
      Callback to update this app state (if enabled) prior to rendering. (Invoked once per frame.)
      Specified by:
      update in interface com.jme3.app.state.AppState
      Overrides:
      update in class NamedAppState
      Parameters:
      interval - time interval between frames (in seconds, ≥0)