Top Description Fields Constructors Methods
org.lwjgl.util

public Class Timer

extends Object
Class Inheritance
Imports
org.lwjgl.Sys

A hires timer. This measures time in seconds as floating point values. All Timers created are updated simultaneously by calling the static method tick(). This ensures that within a single iteration of a game loop that all timers are updated consistently with each other.
Author
cix_foo
Version
$Revision$ $Id$

Field Summary

Modifier and TypeField and Description
private static long
private long
private boolean
private static final int
private static int
private static long
private long

Constructor Summary

AccessConstructor and Description
public
Timer()

Constructs a timer.

Method Summary

Modifier and TypeMethod and Description
public float

Returns:

the time in seconds, as a float
getTime
()

public boolean

Returns:

whether this timer is paused
isPaused
()

public void
pause()

Pause the timer.

public void
reset()

Reset the timer.

public void
resume()

Resume the timer.

public void
set(float
the new time, in seconds
newTime
)

Set the time of this timer

public static void
tick()

Get the next time update from the system's hires timer.

public String
toString()

Overrides java.lang.Object.toString.

Debug output.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

currentTimeback to summary
private static long currentTime
lastTimeback to summary
private long lastTime
pausedback to summary
private boolean paused
QUERY_INTERVALback to summary
private static final int QUERY_INTERVAL
queryCountback to summary
private static int queryCount
resolutionback to summary
private static long resolution
startTimeback to summary
private long startTime

Constructor Detail

Timerback to summary
public Timer()

Constructs a timer. The timer will be reset to 0.0 and resumed immediately.

Method Detail

getTimeback to summary
public float getTime()
Returns:float

the time in seconds, as a float

isPausedback to summary
public boolean isPaused()
Returns:boolean

whether this timer is paused

pauseback to summary
public void pause()

Pause the timer. Whilst paused the time will not change for this timer when tick() is called.

See Also
resume()
resetback to summary
public void reset()

Reset the timer. Equivalent to set(0.0f);

See Also
set(float)
resumeback to summary
public void resume()

Resume the timer.

See Also
pause()
setback to summary
public void set(float newTime)

Set the time of this timer

Parameters
newTime:float

the new time, in seconds

tickback to summary
public static void tick()

Get the next time update from the system's hires timer. This method should be called once per main loop iteration; all timers are updated simultaneously from it.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Debug output.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object