Tutorials:帧频
来自Starling中文站
原文: http://wiki.starling-framework.org/tutorials/finding_out_the_fps
注意:从1.1的版本开始,Starling包含了一个"showStats"的属性。通过在您的应用中的Starling实例上启用这个属性,您可以在屏幕上直观的看到显示的帧频。
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; } });
这将以每秒发送一次的频率,将帧频输出到控制台。
这里有一个 简单的类,当您使用Sparrow框架的时候,可以用来显示FPS.
翻译: 郭少瑞(NeoGuo)