mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
Fix issue #24: cancel not removing periodic timers.
This commit is contained in:
parent
87b82750ff
commit
ff60ae5372
@ -7,7 +7,7 @@ Contents:
|
||||
------------
|
||||
|
||||
* *gamestate.lua*: Easy gamestate management.
|
||||
* *timer.lua*: Delayed and time-limited function calls.
|
||||
* *timer.lua*: Delayed and time-limited function calls and tweening functionality.
|
||||
* *vector.lua*: 2D vector math.
|
||||
* *vector-light.lua*: Lightweight 2D vector math (for optimisation purposes - leads to potentially ugly code).
|
||||
* *class.lua*: Lightweight object orientation (class or prototype based).
|
||||
|
@ -60,15 +60,16 @@ function Timer:add(delay, func)
|
||||
end
|
||||
|
||||
function Timer:addPeriodic(delay, func, count)
|
||||
local count = count or math.huge -- exploit below: math.huge - 1 = math.huge
|
||||
local count, handle = count or math.huge -- exploit below: math.huge - 1 = math.huge
|
||||
|
||||
return self:add(delay, function(f)
|
||||
handle = self:add(delay, function(f)
|
||||
if func(func) == false then return end
|
||||
count = count - 1
|
||||
if count > 0 then
|
||||
self:add(delay, f)
|
||||
self.functions[handle] = delay
|
||||
end
|
||||
end)
|
||||
return handle
|
||||
end
|
||||
|
||||
function Timer:cancel(handle)
|
||||
|
Loading…
Reference in New Issue
Block a user