码迷,mamicode.com
首页 > 其他好文 > 详细

06 显示fps帧频

时间:2020-01-18 01:32:46      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:tick   fun   txt   phi   cti   raw   date()   tag   time()   

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

标签:tick   fun   txt   phi   cti   raw   date()   tag   time()   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!