突然,一个简单的动画在 Chrome(大约 30fps)和 firefox(大约 7fps)中具有不同的帧速率。 这是正确的行为吗?我可以在动画函数中调整 framRate 吗?
最佳答案
试试这个
// variables accessible from within function(frame)
var frameCount = 0;
var currentSecond = 0;
var frameRate = 0;
// within function(frame), called with current time on each new frame
function updateFrameRate(time) {
var second = Math.floor(time / 1000); // ms to integer seconds
if (second != currentSecond) {
frameRate = frameCount;
frameCount = 0;
currentSecond = second;
}
frameCount ++;
}
一个简单的实现,“帧间隔为 1 秒”。您可以使用 5 秒间隔的帧来平滑它
您可以在这里找到更多信息Animation, FPS, and KineticJS
关于kineticjs - 不同浏览器上帧速率数的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18772807/