BlitzMax/Modules/Events/Timers

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Functions[edit | edit source]

CreateTimer[edit | edit source]

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

Description: Create a timer

Returns: A new timer object

Information: 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.

TimerTicks[edit | edit source]

Function TimerTicks( timer:TTimer )

Description: Get timer tick counter

Returns: The number of times timer has ticked over

WaitTimer[edit | edit source]

Function WaitTimer( timer:TTimer )

Description: 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

StopTimer[edit | edit source]

Function StopTimer( timer:TTimer )

Description: Stop a timer

Information: Once stopped, a timer can no longer be used.