<分区>
我很抱歉打扰你,我怀疑除了我自己之外的任何人都认为这是微不足道的问题。我尽力自己寻找答案,但无法找到。
为了让您了解我不了解的地方,我将为您提供一个取自 answer 的示例至 another question在这里问。
我在这个例子的上下文中的问题:newtime
的行为是什么?为什么需要将其定义为参数才能使此功能起作用?它从哪里获得它的值(value)?
startAnimating(5);
function startAnimating(fps) {
fpsInterval = 1000 / fps;
then = window.performance.now();
startTime = then;
console.log(startTime);
animate();
}
function animate(newtime) {
// (...)
requestAnimationFrame(animate);
now = newtime;
elapsed = now - then;
if (elapsed > fpsInterval) {
then = now - (elapsed % fpsInterval);
// (...)
}
}
我将不胜感激任何回应。谢谢。