Contains a function that is scheduled to be executed when a condition is met.

Available since

0.1.0

.

Constructor

new(name:String, f:ConditionalF ‑> Void, condition:() ‑> Bool, once:Bool)

Creates an nb.Timer.ConditionalF instance.

Parameters:

name

A name to identify the instance.

f

The scheduled function. Will have the instance as argument.

condition

When this function returns true, f gets executed.

once

Whether the associated function is set to be executed only once. If false, the function is executed every frame as long as condition returns true.

Variables

name:String

A name to identify this instance.

once:Bool

Whether the associated function is set to be executed only once. If false, the function is executed every frame as long as condition returns true.

condition:() ‑> Bool

When this function returns true, f gets executed.

f:ConditionalF ‑> Void

The scheduled function. Will have this instance as argument.

Methods

tick(dt:Float):Bool

Updates variables and executes the associated function if the condition is met.

Parameters:

dt

An amount of time elapsed, in seconds.

Returns:

true if this instance should cease to be executed, false otherwise.