local UIManager=require"uimanager"
local m_UpdateInterval=1
local m_Accum=0
local m_Frames=0
local m_TimeLeft=0
local function update()
m_TimeLeft = m_TimeLeft-Time.deltaTime
m_Accum = m_Accum+(Time.timeScale / Time.deltaTime)
m_Frames=m_Frames+1
if (m_TimeLeft <= 0) then
if UIManager.isshow("dlguimain") then
local fps = m_Accum/m_Frames
local str = string.format("FPS:%.2f",fps)
UIManager.call("dlguimain","RefreshFPS",str)
end
m_TimeLeft = m_UpdateInterval
m_Accum =0
m_Frames = 0
end
end
local function init()
m_TimeLeft = m_UpdateInterval
gameevent.evt_update:add(update)
end
return{
init = init,
update = update,
}
local m_UpdateInterval=1
local m_Accum=0
local m_Frames=0
local m_TimeLeft=0
local function update()
m_TimeLeft = m_TimeLeft-Time.deltaTime
m_Accum = m_Accum+(Time.timeScale / Time.deltaTime)
m_Frames=m_Frames+1
if (m_TimeLeft <= 0) then
if UIManager.isshow("dlguimain") then
local fps = m_Accum/m_Frames
local str = string.format("FPS:%.2f",fps)
UIManager.call("dlguimain","RefreshFPS",str)
end
m_TimeLeft = m_UpdateInterval
m_Accum =0
m_Frames = 0
end
end
local function init()
m_TimeLeft = m_UpdateInterval
gameevent.evt_update:add(update)
end
return{
init = init,
update = update,
}

本文介绍了一个用Lua编写的FPS监测模块,该模块能够定期计算并显示游戏或应用的平均帧率(FPS)。通过与UIManager交互,将计算出的FPS数据显示在指定的UI界面上。
16万+

被折叠的 条评论
为什么被折叠?



