Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
application:getFps() always "60" — Gideros Forum

application:getFps() always "60"

UglyOwlUglyOwl Member
edited December 2015 in General questions
I've been digging for the answer, couldn't find why
application:getFps()
always returns "60". It stays the same if I change Hardware Frame Rate in the Player or change FPS in the project settings.

(But I figured out how event.deltaTime works :) It's a neat one)

Comments

  • it works for me. What are you using OSX or Windows?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • It's under Windows, Gideros 2015.10.
    The code is like this:
    stage:addEventListener(Event.ENTER_FRAME, function(event)
    	bmp:setRotation(bmp:getRotation()+50*event.deltaTime);
        text:setText(tostring(application:getFps()) .. ", deltaTime=" .. tostring(event.deltaTime))
    end)
  • I have this at the beginning of the code:
    local frameRate=application:getFps()
    Then this in the enter_frame event...
    	local skip=event.deltaTime*frameRate
    	if skip>1.2 then
    		if frameBalancer<(#objectsAvailable-8) then
    			frameBalancer=frameBalancer+5
    		end
    	end
    	if skip>1.5 then
    		skip=2
    	else
    		skip=1
    		if frameCounter%30==0 and frameBalancer>0 then
    			frameBalancer=frameBalancer-1
    		end
    	end
     
    	local usage=(application:getTextureMemoryUsage()/1024)
    	if usage~=oldUsage then
    		oldUsage=usage
    		print("Texture usage: "..usage.."MB")
    	end
        local fps = 1/event.deltaTime  
    	if fps<40 then print("FPS: "..floor(fps)) end
     
    	frameCounter=frameCounter+1
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • The balancer routine is just for me to limit the number of moving object on screen automatically to within only having 3 objects.

    My game never goes over 2 frames - if it did then the skip would be too much - so I limit the skip to 2. I then multiply every movement by skip - so skip would either mult by 1 (the same number) or by 2 (I skipped a frame).
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • You will need oldUsage, frameBalancer somewhere in the main program = 0.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Thank you for code snippets @SinisterSoft !

    So it seems that
    application:getFps()
    only returns what was set by
    application:setFps()
    I was wrongly assuming that it's a dynamic value determined by the actual viewer
  • I'm still a little bit confused. How does Project Properties FPS come into play?
  • that should be the value returned by getFps()
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • I probably wrong, but i think currently it's like this:

    Desktop export : Project Properties is the only value that would be looked on, so setFps won't do anything.
    Mobile export : setFps works as it should be.
  • john26john26 Maintainer
    Accepted Answer
    Project Properties sets the initial value of FPS when the app starts. You can then change it using setFps. This is the case for both desktop and mobile devices. Note that the value you set in setFps is a target value. The device will never run faster than this but it may be slower if the app cannot keep up.
  • Now it makes sense

    Thank you for clarification!
Sign In or Register to comment.