南锋

南奔万里空,脱死锋镝余

Cocos2dx-lua Using schedule Timer

Development Environment: Cocos2dx 3.17
Development Language: Lua
Timers are essential in game development. Below is a simple introduction to using timers in Cocos2dx-lua.

Example Code

1
2
3
4
5
local scheduler = require("framework.scheduler") 
local handler = scheduler.scheduleGlobal(function()
-- Actions to perform
end,
0.2) -- Interval
1
scheduler.unscheduleGlobal(handler) -- Cancel the timer
+