为什么我的控制台打印不出loop?
HTML body 部分代码:
<body>
<div class = "all_bg">
<div id = "allcanvas">
<canvas id = "canvas1" width = "800" height = "600">
</canvas>
<canvas id="canvas2" width="800" height = "600">
</canvas>
</div>
</div>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/commonFunctions.js"></script>
</body>
</html>
JS 代码:
var can1,can2;
var ctx1,ctx2;
function game()
{
init();
gameloop();
}
function init()
{
can1 = document.getElementById("canvas1");
ctx1 = can1.getContext(); //fishes dust UI circle
can2 = document.getElementById("canvas2");
ctx2 = can2.getContext(); //background ane fruits
}
function gameloop()
{
window.requestAnimFrame(gameloop);
console.log("loop");
}