|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.holub.life.Clock
public class Clock
The Clock
class handles the timing of gameboard
updates. It creates its own menu (which sets the clock speed),
and sends notifications off to any observers every time the
clock "ticks."
12-8-2004 AIH Added a kludge to the clock-tick handler that
checks whether any menu item is active before it
allows the clock to tick. This mod fixes a bug
that caused the running game to overwrite any
displayed menus. See menuIsActive()
for
details.
Nested Class Summary | |
---|---|
static interface |
Clock.Listener
Implement this interface to be notified about clock ticks. |
Method Summary | |
---|---|
void |
addClockListener(Clock.Listener observer)
Add a listener that's notified every time the clock ticks: Clock.instance().addClockListener ( new Clock.Listener() { public void tick() { System.out.println("tick!") |
static Clock |
instance()
The clock is a singleton. |
void |
startTicking(int millisecondsBetweenTicks)
Start up the clock. |
void |
stop()
Stop the clock |
void |
tick()
Force the clock to "tick," even if it's not time for a tick. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Clock instance()
Clock.instance()
. It's illegal to call
new Clock()
.
public void startTicking(int millisecondsBetweenTicks)
millisecondsBetweenTicks
- The number of milliseconds between
ticks. A value of 0 indicates that
the clock should be stopped.public void stop()
public void addClockListener(Clock.Listener observer)
Clock.instance().addClockListener ( new Clock.Listener() { public void tick() { System.out.println("tick!"); } } );
public void tick()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |