|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.golden.gamedev.engine.timer.SystemTimer
public class SystemTimer
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 |
---|
public SystemTimer()
SystemTimer
.
Method Detail |
---|
public void startTimer()
BaseTimer
startTimer
in interface BaseTimer
BaseTimer.getCurrentFPS()
,
BaseTimer.getFPS()
public void stopTimer()
BaseTimer
stopTimer
in interface BaseTimer
public long sleep()
BaseTimer
To call this method, timer must be in running state.
sleep
in interface BaseTimer
BaseTimer.startTimer()
,
BaseTimer.getFPS()
public boolean isRunning()
BaseTimer
Timer is running when BaseTimer.startTimer()
is called.
isRunning
in interface BaseTimer
BaseTimer.startTimer()
public int getCurrentFPS()
BaseTimer
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.
getCurrentFPS
in interface BaseTimer
BaseTimer.getFPS()
,
BaseTimer.startTimer()
public int getFPS()
BaseTimer
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()
.
getFPS
in interface BaseTimer
BaseTimer.getCurrentFPS()
,
BaseTimer.setFPS(int)
public void setFPS(int fps)
BaseTimer
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.
setFPS
in interface BaseTimer
fps
- requested frame per secondBaseTimer.getCurrentFPS()
public long getTime()
BaseTimer
getTime
in interface BaseTimer
public void refresh()
BaseTimer
refresh
in interface BaseTimer
|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |