Do completed Timers get removed from Scene?

6 views
Skip to first unread message

Thomer Gil

unread,
May 3, 2020, 8:29:48 PM5/3/20
to excaliburjs
Hi. This is likely due to my poor code reading skills, but I can find no evidence that suggests that expired Timers get removed from Scenes, even if Timer.complete is true. Is my reading correct? Does it matter? Is there a (small) performance penalty associated with going through all Timers on a Scene? Do I need to manually track timers and remove them from the scene after they went off? Thank you.

DaVince

unread,
May 6, 2020, 12:13:56 PM5/6/20
to excaliburjs
I checked the source and found the following:

Once a timer completes, it just seems to mark itself as 'complete' and fires the callback defined. So in the scene's list of timers to update, it does not remove itself from any scene. I can't really tell but I think they just keep updating doing nothing in the background.

You can use isTimerActive(timer) to find out whether a timer is still active and either scene.cancelTimer(timer) or timer.cancel() to safely remove it if it's the case. I think you might also be able to use cancelTimer() at the end of your callback, or limit the amount of timers you use and make use of its looping mechanism instead.
Reply all
Reply to author
Forward
0 new messages