Merge pull request #42 from headchant/master

Makes sense. The same should be done for `hump.signal`.
This commit is contained in:
vrld 2014-11-21 11:53:11 +01:00
commit 03505b9b77

View File

@ -30,7 +30,21 @@ Timer.__index = Timer
local function _nothing_() end local function _nothing_() end
local function new() local function new()
return setmetatable({functions = {}, tween = Timer.tween}, Timer) local timer = setmetatable({functions = {}, tween = Timer.tween}, Timer)
return setmetatable({
new = new,
update = function(...) return timer:update(...) end,
do_for = function(...) return timer:do_for(...) end,
add = function(...) return timer:add(...) end,
addPeriodic = function(...) return timer:addPeriodic(...) end,
cancel = function(...) return timer:cancel(...) end,
clear = function(...) return timer:clear(...) end,
tween = setmetatable({}, {
__index = Timer.tween,
__newindex = function(_,k,v) Timer.tween[k] = v end,
__call = function(t,...) return timer:tween(...) end,
})
}, {__call = new})
end end
function Timer:update(dt) function Timer:update(dt)
@ -174,17 +188,4 @@ end})
local default = new() local default = new()
-- the module -- the module
return setmetatable({ return default
new = new,
update = function(...) return default:update(...) end,
do_for = function(...) return default:do_for(...) end,
add = function(...) return default:add(...) end,
addPeriodic = function(...) return default:addPeriodic(...) end,
cancel = function(...) return default:cancel(...) end,
clear = function(...) return default:clear(...) end,
tween = setmetatable({}, {
__index = Timer.tween,
__newindex = function(_,k,v) Timer.tween[k] = v end,
__call = function(t,...) return default:tween(...) end,
})
}, {__call = new})