在 Web JavaScript 中,要实现流畅的游戏循环,最好的方法就是使用
requestAnimationFrame
function gameLoop(){ start(); generateWord(); // request the next animation frame window.requestAnimationFrame(gameLoop); }
有关更多信息,请查看 MDN 文档。
我希望这有帮助。