Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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.

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

### running

    public boolean running

### one_shot

    public boolean one_shot

### parent_obj

    public JGObject parent_obj

### parent_state

    public java.lang.String parent_state

Constructor Detail

### 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

### JGTimer

    public JGTimer(int frames_to_alarm,
                   boolean one_shot,
                   JGObject parent)

  Create timer which has an object as parent.

  Parameters:
    `frames_to_alarm` - 0 = callback just before next frame.
    `one_shot` - true = run only once, false = run repeatedly

### JGTimer

    public JGTimer(int frames_to_alarm,
                   boolean one_shot,
                   java.lang.String parent)

  Create timer which has a specific gamestate as parent.

  Parameters:
    `frames_to_alarm` - 0 = callback just before next frame.
    `one_shot` - true = run only once, false = run repeatedly

Method Detail

### set

    public void set(int frames_to_alarm,
                    boolean one_shot)

### tick

    public boolean tick(double speed)

  Tick function, as called by the engine implementation. Returns true when the timer has to be removed.

### alarm

    public abstract void alarm()

  define your alarm action here.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD