Timer Object

Top  Previous  Next

The timer object.

Methods

Return

Signature

Flags


start()



stop()



deinit()


Timer::start()

Starts the timer. If already running the timer will be restarted.

Timer::stop()

Stops the timer.

Timer::deinit()

Stops and destroys the timer. After this call the timer object is invalid. Do not keep a reference to it any longer.

Example

local counter = 0

local timerObj = timer.new(500, function(t)

  counter = counter + 1

  if (counter>= 50) then

        t:deinit()

  end

  print("hello", counter)

end)

 

timerObj:start()