The simple way is to just use an enterFrame listener that keeps a check on the current time and then displays an average every 60 (or 30) frames. I have some code somewhere (and it's also available on here if you search) that will do that for you - although I suspect someone will post some code before I get chance to...
WhiteTree Games - Home, home on the web, where the bits and bytes they do play! #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Ok, thanks for the hint. Thats exactly what I do now. On "enterFrame" a counter gets increased. When this counter is higher then Application:getFps() I do measure times using os.timer() and do some math et voila - fps. (Btw: It's around 60 while rendering about 2000 sprites .)
-- --------------------------------------------------------------------------- local methods required to put an FPS counter on the screen...local frame =0local timer =os.timer()local qFloor =math.floorlocal fps, scount
localfunction updateFPS(e)
frame = frame + 1if frame ==60thenlocal currentTimer =os.timer()
fps:setText(""..qFloor(60/(currentTimer - timer)))local width = fps:getWidth()
fps:setPosition(WIDTH-(width+10), 28)--HEIGHT-10)
frame =0; timer = currentTimer
endend-- -------------------------------------------------------------------------
initFPS =function(group)
fps = TextField.new(nil," ")
fps:setTextColor(0x00FFFF)
fps:setScale(2,2)
fps:addEventListener(Event.ENTER_FRAME,updateFPS)
group:addChild(fps)end
initFPS(stage)-- Add a quick FPS counter on the screen (REMOVE for final build)
WhiteTree Games - Home, home on the web, where the bits and bytes they do play! #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Comments
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill