I need to call some of the functions after some time. I've done this like that:
function doAfterDelay(delay, f)
local t = Timer.new(delay*1000, 1)
t:start()
t:addEventListener(Event.TIMER_COMPLETE, f, t)
end |
and call:
if *something* then
doAfterDelay(0.08, function(t, event)
-- some code here
t = nil
event:stopPropagation()
end)
end |
Is that method good? Can it cause a memory leak, or I do not need to worry about it?
I have another solution, but this is a bit easier to understand)))
P.S. Sorry if my eng. is not good enough
Comments
One alternative could be to keep a counter in enterframe, and do something on certain count.
Likes: rrraptor
Likes: pie, antix, Tom2012
Asking because my game has a zillion delayedcall timers
Underneath Timer.delayedCall does exactly as creating new timer, setting events, starting timer and returning it.
So it would behave the same way, only less code for you to write