main.js 文件中报错:
window.requestAnimFrame(gameloop);
错误内容:main.js:41 Uncaught TypeError: window.requestAnimFrame is not a function
你把main和commonFunctions这两个文件在html页面的导入顺序调换一下,commonFunctions 先导入,就可以了
window.requestAnimFrame = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
return window.setTimeout(callback, 1000 / 60);
};
})();
难道不是在声明window.requestAnimFrame?