Шукати в цьому блозі

підрахунок FPS & deltaTime

Синтаксис: Lua
local frame = 0
local timer = os.timer()
local function displayFps()
        frame = frame + 1
        if frame == 60 then
                local currentTimer = os.timer()
                print(60 / (currentTimer - timer))
                frame = 0
                timer = currentTimer   
        end
end

stage:addEventListener(Event.ENTER_FRAME, displayFps)

----------------------------------------------------------------------

Використання  deltaTime

local frameRate=application:getFps()
local fineSkip=0
 
function gameLoop(e)
  fineSkip=e.deltaTime*frameRate
 
  x+=5*fineSkip  -- move 5 pixels if frame rate accurate, else more if slower rate or less if faster rate
 
end
stage:addEventListener(Event.ENTER_FRAME,gameLoop)

-------------------------------------------------
довідка
http://docs.giderosmobile.com/reference/gideros/Core/frameStatistics#Core.frameStatistics
http://docs.giderosmobile.com/reference/gideros/Sprite/Event.ENTER_FRAME

Немає коментарів:

Дописати коментар