GTGE API

com.golden.gamedev.engine.timer
Class SystemTimer

java.lang.Object
  extended by com.golden.gamedev.engine.timer.SystemTimer
All Implemented Interfaces:
BaseTimer

public class SystemTimer
extends Object
implements BaseTimer

The standard timer used in Golden T Game Engine (GTGE) Frame Work.

This timer is using System.currentTimeMillis() and support for time drift calculation.

See BaseTimer for how to use timer engine separated from Golden T Game Engine (GTGE) Frame Work.


Constructor Summary
SystemTimer()
          Constructs new SystemTimer.
 
Method Summary
 int getCurrentFPS()
          Returns timer current frame per second.
 int getFPS()
          Returns the requested frame per second.
 long getTime()
          Returns timer current time in milliseconds.
 boolean isRunning()
          Returns whether the timer is currently running or not.
 void refresh()
          Refreshs timer elapsed time.
 void setFPS(int fps)
          Sets this timer target frame per second to specified frame per second.
 long sleep()
          Sleeps for awhile to achieve requested frame per second and returns the elapsed time since last sleep.
 void startTimer()
          Starts the timer, please set appropriate frame per second first before calling this method.
 void stopTimer()
          Stops this timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemTimer

public SystemTimer()
Constructs new SystemTimer.

Method Detail

startTimer

public void startTimer()
Description copied from interface: BaseTimer
Starts the timer, please set appropriate frame per second first before calling this method.

Specified by:
startTimer in interface BaseTimer
See Also:
BaseTimer.getCurrentFPS(), BaseTimer.getFPS()

stopTimer

public void stopTimer()
Description copied from interface: BaseTimer
Stops this timer.

Specified by:
stopTimer in interface BaseTimer

sleep

public long sleep()
Description copied from interface: BaseTimer
Sleeps for awhile to achieve requested frame per second and returns the elapsed time since last sleep.

To call this method, timer must be in running state.

Specified by:
sleep in interface BaseTimer
Returns:
Elapsed time since last sleep.
See Also:
BaseTimer.startTimer(), BaseTimer.getFPS()

isRunning

public boolean isRunning()
Description copied from interface: BaseTimer
Returns whether the timer is currently running or not.

Timer is running when BaseTimer.startTimer() is called.

Specified by:
isRunning in interface BaseTimer
See Also:
BaseTimer.startTimer()

getCurrentFPS

public int getCurrentFPS()
Description copied from interface: BaseTimer
Returns timer current frame per second.

Current frame per second is the actual frame per second the player machine could achieve.

Because of one and many things (ie: the incapability of the player machine), the current frame per second can be differ from the requested frame per second.

Specified by:
getCurrentFPS in interface BaseTimer
Returns:
Timer current frame per second.
See Also:
BaseTimer.getFPS(), BaseTimer.startTimer()

getFPS

public int getFPS()
Description copied from interface: BaseTimer
Returns the requested frame per second.

Requested frame per second is the target frame per second to achieve (the number set in BaseTimer.setFPS(int) method).

Because of one and many things (ie: the incapability of the player machine), a high requested frame per second may not always be achieved.

To get the actual fps see BaseTimer.getCurrentFPS().

Specified by:
getFPS in interface BaseTimer
Returns:
Requested frame per second.
See Also:
BaseTimer.getCurrentFPS(), BaseTimer.setFPS(int)

setFPS

public void setFPS(int fps)
Description copied from interface: BaseTimer
Sets this timer target frame per second to specified frame per second.

This timer is ordered to run as fast as this frame per second, but the actual fps achieved is depending of the player machine ability.

Specified by:
setFPS in interface BaseTimer
Parameters:
fps - requested frame per second
See Also:
BaseTimer.getCurrentFPS()

getTime

public long getTime()
Description copied from interface: BaseTimer
Returns timer current time in milliseconds.

Specified by:
getTime in interface BaseTimer

refresh

public void refresh()
Description copied from interface: BaseTimer
Refreshs timer elapsed time.

Specified by:
refresh in interface BaseTimer

GTGE API

Copyright © 2003-2005 Golden T Studios. All rights reserved. Use is subject to license terms.
GoldenStudios.or.id