jgame
Class JGTimer
java.lang.Object
jgame.JGTimer
- public abstract class JGTimer
- extends java.lang.Object
A timer that generates a callback after a certain number of frames. It
can conveniently be used as a "one liner class", i.e. as an inner class
within a context where it can set a variable or call a method. i.e.
new JGTimer (10,true) { alarm() { doSomething(); } };
Timers are updated just before the beginning of a frame. Any objects
they add or delete are immediately updated before the frame starts.
Constructor Summary |
JGTimer(int frames_to_alarm,
boolean one_shot)
Create timer; the timer may be one-shot (it runs only once, then
triggers the alarm and removes itself), or continuous (it continues
running and triggering the alarm) |
Method Summary |
abstract void |
alarm()
define your alarm action here. |
void |
set(int frames_to_alarm,
boolean one_shot)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
running
public boolean running
one_shot
public boolean one_shot
JGTimer
public JGTimer(int frames_to_alarm,
boolean one_shot)
- Create timer; the timer may be one-shot (it runs only once, then
triggers the alarm and removes itself), or continuous (it continues
running and triggering the alarm)
- Parameters:
frames_to_alarm
- 0 = callback just before next frame.one_shot
- true = run only once, false = run repeatedly
set
public void set(int frames_to_alarm,
boolean one_shot)
alarm
public abstract void alarm()
- define your alarm action here.