第一步:
在组件上,挂载 LuaLooper 脚本(这是驱动tolua里面Update)
第二步:
找到tolua 里面的event 脚本 把下面代码复制进来
function _event:Add(func,obj)
local events = UpdateBeat:CreateListener(func,obj)
UpdateBeat:AddListener(events)
UpdateBeat(func)
return events
end
func 是你要执行的update,obj 是这个update所在的表
第三步:
local this = {}
this.events
–需要执行的时候写下面这行代码
this.events = UpdateBeat:Add(this.Update,this)
–移除Update
–UpdateBeat:RemoveListener(this.events)
function this.Update()
print(‘我被调用了’)
end
return this
–这就是 在tolua里调用Update