06 显示fps帧频
Posted heteng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了06 显示fps帧频相关的知识,希望对你有一定的参考价值。
需要看fps就用下面这段代码即可
var FPS = {};
FPS.time = 0;
FPS.FPS = 0;
FPS.startFPS = function (stage){
FPS.shape = new createjs.Shape();
FPS.shape.graphics.beginFill("#000000").drawRect(0, 0, 100, 20);
stage.addChild(FPS.shape);
FPS.txt =new createjs.Text("", "15px Arial", "#ffffff");
stage.addChild(FPS.txt);
createjs.Ticker.addEventListener("tick", FPS.TickerFPS);
}
FPS.TickerFPS = function (event)
{
FPS.date = new Date();
FPS.currentTime = FPS.date.getTime();
if(FPS.time!=0)
{
FPS.FPS = Math.ceil(1000/(FPS.currentTime - FPS.time));
}
FPS.time = FPS.currentTime;
FPS.txt.text = "FPS: "+FPS.FPS;
}
FPS.startFPS(stage);
以上是关于06 显示fps帧频的主要内容,如果未能解决你的问题,请参考以下文章