首页 > 其他 > 详细

06 显示fps帧频

时间:2020-01-18 00:49:41      阅读:111      评论:0      收藏:0      [点我收藏+]

需要看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帧频

原文:https://www.cnblogs.com/heteng/p/12207928.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!