Javascript - Can't Adjust FrameRate - requestanimationframe

前端 未结 7 2262
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 03:50

I start the loop

function gameLoop(){
   update();
   draw();
   requestAnimFrame(gameLoop);
}

var requestAnimFrame =  window.requestAnimationFrame ||
                  


        
7条回答
  •  天命终不由人
    2021-02-06 04:09

    That's how requestAnimationFrame works. If you want a specific framerate, use setTimeout only.

    Usually you would take a parameter, which is the current time. Compare it to the last frame's time to find out how far along the animation should move.

提交回复
热议问题