Shapes 3D  3.0
 All Classes Functions Variables Pages
shapes3d.utils.IntervalTimer Class Reference

Public Member Functions

 IntervalTimer ()
 
 IntervalTimer (PApplet papp)
 
void pre ()
 
void turnOffAuto ()
 
void update ()
 
float elapsedTime ()
 
float runTime ()
 
void reset ()
 

Detailed Description

Simple timer class to measure elapsed time.

The main method for getting the elapsed time is -

public float elapsedTime() 

but this method behaves differently depending on which constructor is used.
MANUAL MODE
If created using the default constructor (i.e. the one without parameters) then the method will return the time since it was last called. So can be used to measure the elapsed time between any events e.g. between mouse clicks. It can also be used to measure how long something takes to perform some code e.g.

void aMethod(){
  int_timer.elapsedTime(); // don't need to store time now
  // some lengthy code here perhaps
  float t = int_timer.elapsedTime(); // t = time to perform the action
}


AUTO MODE
If you use pass a PApplet object to the constructor then the method will always return the time between the current frame and the previous frame, no matter how many times it is called.

Author
Peter Lager

Constructor & Destructor Documentation

shapes3d.utils.IntervalTimer.IntervalTimer ( )

If you use this constructor you will get a simple interval timer that returns the time between call to elapsedTime().

shapes3d.utils.IntervalTimer.IntervalTimer ( PApplet  papp)

You must use this constructor Using this constructor means that the gameTime and elapsedTime are automatically updated for you just before the draw method is called. So there is no need for you to call the setLapTime() method.

Parameters
pappthe PApplet object

Member Function Documentation

float shapes3d.utils.IntervalTimer.elapsedTime ( )

Get the elapsed time appropriate for the timer mode.

Returns
time in seconds
void shapes3d.utils.IntervalTimer.reset ( )

Reset the clock.

float shapes3d.utils.IntervalTimer.runTime ( )

Get the time since the timer was created/reset

Returns
time in seconds
void shapes3d.utils.IntervalTimer.update ( )

In AUTO mode this is called for you just before the draw() method is executed. So it will measure the elapsed time between frames. To mesure the elapsed time between frames in MANUAL mode at the start of the draw method so if you have a timer object called

inet_timer

then at the at the start of the draw() method you update the timer with

int_timer.update();


and get the inter-frame time with

int_timer.elapsedTime();



The documentation for this class was generated from the following file: