Hi guys! I wanted to ask if this technique is a good idea. I’m using enough timers to create a game and I need to group them in a table and cancel all of them in scene:hide with a function.
create a table
--timers local t = {} --local table for all timers
use some timers
t.tmr1 = timer.performWithDelay(...) t.tmr2 = timer.performWithDelay(...) t.tmr3 = timer.performWithDelay(...) … t.tmr17 = timer.performWithDelay(...) etc
I think that if I am using a table I have a key / values which I can use in the following way to cancel everything at once.
cancel all timers at once
--cancel all timers local function cancelAllTimers() for k, v in pairs(t) do timer.cancel(v) end k = nil end
I do not receive any errors on the console or on the devices. I just want to know if doing this is a good practice?
***Sometimes I feel doubt about what I do and would like someone with more experience tell me if I’m on the right way or I should continue evaluating other methods***
Thanks in advance
DoDi