In older versions of Cocos Creator, you used to be able to call cc.profiler.getFrameRate()
In version 1.6.1, that function does not exist anymore. Is there a replacement?
In older versions of Cocos Creator, you used to be able to call cc.profiler.getFrameRate()
In version 1.6.1, that function does not exist anymore. Is there a replacement?
In update functions I think you can use the dt parameter which is the delta time passed from the last frame. If you need the fps it’s simply 1/dt.
update: function (dt) {
console.log("fps: " + 1/dt);
}
That’s the “immediate” FPS, from just the last frame, as opposed to cc.profiler.getFrameRate()
, which gave the average FPS over the last 0.5 seconds.
I suppose I could schedule a task for every 0.5 seconds, then use cc.director.getTotalFrames()
to know how many frames have passed since the last FPS check, and divide frames over time.