GF4J 0.9.4 Beta

gameframe.engines.jdk12x
Class CTimer

java.lang.Object
  |
  +--gameframe.engines.jdk12x.CTimer
All Implemented Interfaces:
Finalizable, Timer

class CTimer
extends java.lang.Object
implements Timer, Finalizable

Interface for a generic timer class that times the (average or exact, depending on implementation) time between the calls made to the calculateTime() method. Useful for e.g. finding out how long a main game loop takes and refining some timing accordingly.

Since:
GameFrame for Java 0.9
Version:
GameFrame for Java 0.9.3

Field Summary
private  float m_averageTime
          The average time that has gone in one invokation of calculateTime().
private  int m_count
          The number of invokations of calculateTime().
private  CEngineFactory m_engineFactory
          The engine factory that created this timer.
private  long m_lastCalculationTime
          The last time the average value was calculated.
 
Constructor Summary
(package private) CTimer(CEngineFactory engineFactory)
          Constructs a timer.
 
Method Summary
 float calculateTime()
          When invoked calculates the time that has expired since the last invokation in milliseconds.
 void finalize()
          Frees all the resources used by this class.
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_engineFactory

private CEngineFactory m_engineFactory
The engine factory that created this timer.

m_averageTime

private float m_averageTime
The average time that has gone in one invokation of calculateTime().

m_count

private int m_count
The number of invokations of calculateTime().

m_lastCalculationTime

private long m_lastCalculationTime
The last time the average value was calculated.
Constructor Detail

CTimer

CTimer(CEngineFactory engineFactory)
Constructs a timer.
Parameters:
engineFactory - The engine factory that is to be notified about finalization.
Method Detail

calculateTime

public float calculateTime()
When invoked calculates the time that has expired since the last invokation in milliseconds.
Specified by:
calculateTime in interface Timer
Returns:
The time that has gone since last invokation.

finalize

public void finalize()
Frees all the resources used by this class.
Specified by:
finalize in interface Timer
Overrides:
finalize in class java.lang.Object

GF4J 0.9.4 Beta