#Event: Tick()
'Class module
Private Sub Class_Globals
Public Interval As Float = 1 'Interval in seconds
Private DELTA_TIME_COUNTER As Float = 0
Private ParentActivity As Object
Private EventHandle As String
End Sub
'Initializes the object. You can add parameters to this method if needed.
'Example: Initialize(Me, "Timer", 1)
Public Sub Initialize(mParent As Object, mEventHandle As String, mInterval As Float)
ParentActivity = mParent
Interval = mInterval
EventHandle = mEventHandle
End Sub
Sub UpdateTimer(DeltaTime As Float)
DELTA_TIME_COUNTER = DELTA_TIME_COUNTER + DeltaTime
If DELTA_TIME_COUNTER >= Interval Then
DELTA_TIME_COUNTER = 0
If SubExists(ParentActivity, EventHandle & "_Tick") Then
CallSub(ParentActivity, EventHandle & "_Tick")
End If
End If
End Sub
Sub FormatToTime(TimeInSeconds As Float) As String
Dim s1 As String = NumberFormat(Floor(TimeInSeconds / 60), 2, 0)
Dim s2 As String = NumberFormat(TimeInSeconds Mod 60, 2, 0)
Return s1 & ":" & s2
End Sub