-
Notifications
You must be signed in to change notification settings - Fork 9
Guide_Timer
pojol edited this page Jun 6, 2018
·
5 revisions
这个用例可以初步了解下 消息的 侦听 和 发送 ,以及内置模块的使用场景。
完整代码位于 script/test_timer.lua
module = {
before_init = function(dir) end,
init = function() end,
execute = function() end,
shut = function() end,
after_shut = function() end,
}
module.init = function()
-- 创建一个1秒后触发的定时器
_tid = self:delay(1000, function()
-- timer arrived
end)
-- 删除一个还未被触发的定时器
self:rmvDelay(_tid)
-- 创建一个一天后触发的定时器 (明天7点30分触发
_tid = self:delayDay(7, 30, function()
-- timer arrived
end)
end