How to find out the current Framerate

Note: Beginning with version 1.1, Starling contains a “showStats” property. Enable it on your Starling instance, and the framerate will be displayed directly on the screen.

To find out the actual frame rate, you can use the following code snippet. Add it e.g. to the constructor of your game class.

var frameCount:int = 0;
var totalTime:Number = 0;
addEventListener(Event.ENTER_FRAME, function(event:EnterFrameEvent):void
{
    totalTime += event.passedTime;
    if (++frameCount % 60 == 0)
    {
        trace("fps: " + frameCount / totalTime);
        frameCount = totalTime = 0;
    }
});

This will display the actual frames per second to the console.

Here is a simple class that will show you the FPS in sparrow when your device is unplugged.

  tutorials/finding_out_the_fps.txt · Last modified: 2013/01/22 16:40 by 115.254.92.121
 
Powered by DokuWiki