|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jgame.JGTimer
public abstract class JGTimer
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.
Timers can be made dependent on certain game states or objects. If the particular game state is exited or the object is removed at the beginning of the frame, the timer removes itself without invoking the alarm.
Field Summary | |
---|---|
boolean |
one_shot
|
JGObject |
parent_obj
|
java.lang.String |
parent_state
|
boolean |
running
|
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) |
|
JGTimer(int frames_to_alarm,
boolean one_shot,
JGObject parent)
Create timer which has an object as parent. |
|
JGTimer(int frames_to_alarm,
boolean one_shot,
java.lang.String parent)
Create timer which has a specific gamestate as parent. |
Method Summary | |
---|---|
abstract void |
alarm()
define your alarm action here. |
void |
set(int frames_to_alarm,
boolean one_shot)
|
boolean |
tick(double speed)
Tick function, as called by the engine implementation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public boolean running
public boolean one_shot
public JGObject parent_obj
public java.lang.String parent_state
Constructor Detail |
---|
public JGTimer(int frames_to_alarm, boolean one_shot)
frames_to_alarm
- 0 = callback just before next frame.one_shot
- true = run only once, false = run repeatedlypublic JGTimer(int frames_to_alarm, boolean one_shot, JGObject parent)
frames_to_alarm
- 0 = callback just before next frame.one_shot
- true = run only once, false = run repeatedlypublic JGTimer(int frames_to_alarm, boolean one_shot, java.lang.String parent)
frames_to_alarm
- 0 = callback just before next frame.one_shot
- true = run only once, false = run repeatedlyMethod Detail |
---|
public void set(int frames_to_alarm, boolean one_shot)
public boolean tick(double speed)
public abstract void alarm()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |