It's really not complicated though. Call me a nub. I dare you.
Docs:
Code: Select all
--Functions
hourglass:updateAll(dt) --Updates all the timers.
hourglass:getAll() --Returns all timers
hourglass:resetAll() --Restarts all timers
hourglass:pauseAll(boolean) --Pauses all timers.
hourglass:destroyAll() --Destroys all the timers.
---------------------------------------------------------
hourglass.timer:new(delay, function) --Creates a timer with a set delay in milliseconds and a function that will be called.
hourglass.timer:update(dt) --Updates the timer's clock. Returns true and calls its set function if it triggers.
hourglass.timer:pause(boolean) --Pauses the timer.
hourglass.timer:reset() --Restarts the timer
hourglass.timer:destroy() --Destroys the timer.
hourglass.timer:getClock() --Returns the amount of time elapsed.
hourglass.timer:getDelay() --Returns the timer's delay.
hourglass.timer:isTriggered() --Returns if the timer is triggered or not.
hourglass.timer:isPaused() --Returns if the timer is paused or not.
Code: Select all
--Example for 0.5 (uses classes)
hourglass = require 'hourglass.lua'
function love.load()
text = 'D:'
a = hourglass.timer:new(1000, function() text=':D' end)
a:pause(true)
b = hourglass.timer:new(500, function() a:pause(false) end)
end
function love.draw()
love.graphics.print(text, 400, 300)
end
function love.update(dt)
hourglass:update(dt)
end
Update 06/07/10:
-Changed function names
-Added hourglass.timer:reset() and hourglass:resetAll()