brl_timer.md 1.1 KB


id: brl.timer title: BRL.Timer

sidebar_label: BRL.Timer

Functions

Function CreateTimer:TTimer( hertz#,event:TEvent=Null )

Create a timer

CreateTimer creates a timer object that 'ticks' hertz times per second.

Each time the timer ticks, event will be emitted using EmitEvent.

If event is Null, an event with an id equal to EVENT_TIMERTICK and source equal to the timer object will be emitted instead.

Returns

A new timer object

Function TimerTicks:Int( timer:TTimer )

Get timer tick counter

Returns

The number of times timer has ticked over

Function WaitTimer:Int( timer:TTimer )

Wait until a timer ticks

Returns

The number of ticks since the last call to WaitTimer

Example

timer=CreateTimer( 10 )

Repeat
	Print "Ticks="+WaitTimer( timer )
Forever

Function StopTimer( timer:TTimer )

Stop a timer

Once stopped, a timer can no longer be used.