4
* Encapsulates the logic to manage blinking or simple multi-step logic.
8
static public function timed( timeout : Float )
10
return new Blinker( timeout );
13
public function addState( func : Void -> Void )
19
* Called to indicate that time has elapsed. IF the state has
20
* changed then the appropriate state switcher will be called.
22
public function step( elapsed : Float )
26
var newState = Math.floor( timeout / timeoutFull );
27
if( newState >= states.length )
30
timeout -= states.length * timeoutFull; //ensure equal timing (overlap goes into next bit)
33
//check if we've changed and call the state changer
34
if( newState != curState )
41
var timeoutFull : Float;
44
var states : Array<Void->Void>;
46
function new( timeout : Float )
48
this.timeoutFull = timeout;
51
states = new Array<Void->Void>();