Lib timer

Timer library.

Based on hump.timer.

Functions

new () Create new timer instance.
addPeriodic (delay, func[, count]) Schedule a function that is called periodically.
doFor (delta, func[, after]) Execute a function every frame until time expires.
cancel (handle) Cancel a timer.
clear () Cancel all timers.
update (dt) Update the timer.
tween (duration, subject, target[, method='linear'][, after], ...) Create a tween.


Functions

new ()
Create new timer instance. By default all functions are called on a single global instance.

Returns:

    Timer timer instance

Usage:

     local specialTimer = timer.new()
     specialTimer.add(10, function() print("yay!") end) -- print "yay!" after 10 seconds
     specialTimer.update( dt ) -- call this every frame
addPeriodic (delay, func[, count])
Schedule a function that is called periodically. Add a function that will be called count times every delay seconds. If count is omitted, the function will be called until it returns false or timer.cancel or timer.clear is called.

Parameters:

  • delay number seconds between consecutive calls
  • func function function to execute periodically
  • count number number of times the function is called (optional)

Returns:

    table timer handle
doFor (delta, func[, after])
Execute a function every frame until time expires. Optionally runs after() once delta seconds have passed.

Parameters:

  • delta number number of seconds that the function func will be called
  • func function function to execute every frame
  • after function function to execute once delta seconds expired (optional)
cancel (handle)
Cancel a timer.

Parameters:

  • handle table timer handle
clear ()
Cancel all timers.
update (dt)
Update the timer.

Parameters:

  • dt number delta time
tween (duration, subject, target[, method='linear'][, after], ...)
Create a tween. Readh the hump.timer tween section for more information.

Parameters:

  • duration number duration of tween
  • subject table object to be tweened
  • target table target values
  • method string tweening method (default 'linear')
  • after function function to execute after the tween finished (optional)
  • ... mixed additional arguments for the tweening function (amplitude, period or bounciness)
generated by LDoc 1.4.3 Last updated 2015-04-20 03:01:38