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);

猜你喜欢

转载自www.cnblogs.com/heteng/p/12207928.html
06
FPS
今日推荐