functioncalcLogic() local key_table = {} for k,_ inpairs(remoteData.assets) do table.insert(key_table, k) end local index = 1 local total = #key_table -- 总数量
-- 检验结束回调 localfunctioncheckFinished() self._processFunc(100, "检查更新...(100%)") end
-- 检测一条 localfunctioncheckOne(index) print("检测索引"..index) end
-- update localfunctionupdateHandler() for i=1,1000do if index <= total then checkOne(index) index = index + 1 else -- 循环终止 ifself._checkTimer then cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self._checkTimer) end self._checkTimer = nil checkFinished() return end end -- 刷新进度条 local num = math.floor(index * 100 / total) self._processFunc(num, "资源重新校验中...("..num .."%)") end
-- 分帧检验开启 ifself._checkTimer == nilthen self._checkTimer = cc.Director:getInstance():getScheduler():scheduleScriptFunc(updateHandler, 0, false) end end