Package tripleplay.util
Class Timer
java.lang.Object
react.Slot<Platform>
tripleplay.util.Timer
- All Implemented Interfaces:
react.Reactor.RListener
,react.SignalView.Listener<Platform>
,react.ValueView.Listener<Platform>
Handles execution of actions after a specified delay. Create a
Timer
and connect it to
the Platform.frame
signal:
public class MyGame extends SceneGame {
public final Timer timer = new Timer();
public MyGame (Platform plat) {
plat.frame.connect(timer);
}
}
Then you can register actions to be performed at times in the future like so:
// wherever
game.timer.after(500, () -> {
// this is run after 500ms
});
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A handle on registered actions that can be used to cancel them. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionExecutes the supplied action after the specified number of milliseconds have elapsed.atThenEvery
(int initialMillis, int repeatMillis, Runnable action) Executes the supplied action startinginitialMillis
from now and everyrepeatMillis
there after.Executes the supplied action startingmillis
from now and everymillis
thereafter.void
Methods inherited from class react.Slot
andThen, compose, filtered, onChange
-
Constructor Details
-
Timer
public Timer()Creates a timer instance that can be used to schedule actions. Connect this timer to the frame signal to make it operable.
-
-
Method Details
-
after
Executes the supplied action after the specified number of milliseconds have elapsed.- Returns:
- a handle that can be used to cancel the execution of the action.
-
every
Executes the supplied action startingmillis
from now and everymillis
thereafter.- Returns:
- a handle that can be used to cancel the execution of the action.
-
atThenEvery
Executes the supplied action startinginitialMillis
from now and everyrepeatMillis
there after.- Returns:
- a handle that can be used to cancel the execution of the action.
-
onEmit
-