Environment: Cocos2d-x 3.17
Language: Lua
Use quick-Cocos2d-x’s scheduler helper to run a callback periodically:
1 | local scheduler = require("framework.scheduler") |
Cancel it with the returned handle:
1 | if timerHandle then |
Store the handle on the object that owns the timer and cancel it when the scene or component exits. Otherwise a global callback may keep running and access nodes that have already been destroyed.