Package jme3utilities
Class TimeOfDay
java.lang.Object
com.jme3.app.state.AbstractAppState
jme3utilities.NamedAppState
jme3utilities.TimeOfDay
- All Implemented Interfaces:
com.jme3.app.state.AppState
A named appstate to simulate the time of day in a game.
Each instance is enabled at creation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intduration of a full day (in hours)static final intnumber of minutes in an hourstatic final intnumber of seconds in a daystatic final intnumber of seconds in an hour - declared early due to a dependencystatic final intnumber of seconds in a minute - declared early due to a dependencyFields inherited from class com.jme3.app.state.AbstractAppState
initialized -
Constructor Summary
ConstructorsConstructorDescriptionTimeOfDay(float startHour) Instantiate a new enabled, uninitialized simulation clock, specifying the start time. -
Method Summary
Modifier and TypeMethodDescriptionfloatgetRate()Read the simulation rate.floathour()Determine the simulated time of day in hours.intsecond()Determine the simulated time of day in whole seconds.voidsetHour(float newHour) Alter the simulation time.voidsetRate(float newRate) Alter the simulation rate.toString()Represent this time of day as a text string.voidupdate(float interval) Callback to update this app state (if enabled) prior to rendering.Methods inherited from class jme3utilities.NamedAppState
cleanup, getInfluence, hasInfluenceOver, influence, initialize, isEnabled, isInitialized, postRender, render, setEnabled, stateAttached, stateDetached, stopInfluencingMethods inherited from class com.jme3.app.state.AbstractAppState
getId, setId
-
Field Details
-
hoursPerDay
public static final int hoursPerDayduration of a full day (in hours)- See Also:
-
minutesPerHour
public static final int minutesPerHournumber of minutes in an hour- See Also:
-
secondsPerMinute
public static final int secondsPerMinutenumber of seconds in a minute - declared early due to a dependency- See Also:
-
secondsPerHour
public static final int secondsPerHournumber of seconds in an hour - declared early due to a dependency- See Also:
-
secondsPerDay
public static final int secondsPerDaynumber 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
Represent this time of day as a text string.- Overrides:
toStringin classNamedAppState- 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:
updatein interfacecom.jme3.app.state.AppState- Overrides:
updatein classNamedAppState- Parameters:
interval- time interval between frames (in seconds, ≥0)
-