Timer

cjcliffe edited this page Oct 15, 2011 · 4 revisions

CubicVR.Timer

The Timer class provides basic timing and seeking functions. A Timer is provided by the CubicVR.MainLoop loop function callback.

Constructor:

Timer()

Methods:

start()

Start the timer and initialize time to 0.

Returns:

none

update()

Update the timer for the current frame and step the timer. This will be called automatically by MainLoop.

Returns:

none

stop()

Stop the timer and mark the end_time property.

Returns:

none

reset()

Start the timer and reset time to 0.

Returns:

none

lockFramerate( f_rate )

Force time intervals to f_rate frames per second regardless of actual time.

Parameters:

  • f_rate : Frames per second.

Returns:

none

unlock()

Disable any calls to lockFramerate(..).

Returns:

none

locked()

Checks if the timer is locked or not.

Returns:

true if framerate is locked, false if not.

getMilliseconds()

Get the current time in Milliseconds.

Returns:

Time in Milliseconds

getSeconds()

Get the current time in Seconds.

Returns:

Time in Seconds.

setMilliseconds( milliseconds )

Set the current time in Milliseconds.

Parameters:

  • milliseconds : Millseconds to set the time to.

Returns:

none

setSeconds( seconds )

Set the current time in Seconds.

Parameters:

  • seconds : Seconds to set the time to.

Returns:

none

getLastUpdateSeconds()

Return the time interval between this update and last in Seconds.

Returns:

Time interval betwen update() in Seconds.

getLastUpdateMilliseconds()

Return the time interval between this update and last in Milliseconds.

Returns:

Time interval betwen update() in Milliseconds

getTotalMilliseconds()

Get the total time (excluding pauses and time shifts).

Returns:

Total time in Milliseconds.

getTotalSeconds()

Get the total time (excluding pauses and time shifts).

Returns:

Total time in Seconds

getNumUpdates()

Get the total number of calls to update().

Returns:

Total number of calls to update().

setPaused( paused )

Set the paused state of the timer. While paused the timer will continue to run but maintain the current time.

Parameters:

paused - true or false to pause or unpause, respectively.

Returns:

none

getPaused()

Return the paused state of the timer.

Returns:

true if paused, false if not.