<script>var can1;var can2;var ctx1;var ctx2;var lastTime;var deltaTime;document.body.onload=game;function game(){ init(); gameloop();}function init(){ can1=document.getElementById("canvas1");//fishes,dust,UI,circle ctx1=can1.getContext(); can2=document.getElementById("canvas2");//background,ane,fruits ctx2=can2.getContext(); }function gameloop(){ requestAnimFrame(gameloop);//frame per second(动态时间间隔) var now=date.now(); deltaTime=now-lastTime; lastTime=now; console.log(lastTime)}<script>body> <div class="all_bg"> <div id="allcanvas"> <canvas id="canvas1" width="800px" height="600px"> </canvas> <canvas id="canvas2" width="800px" height="600px"> </canvas> </div> </div> <script type="text/javascript" src="js/main.js"></script> <script type="text/javascript" src="js/commonFunctions.js"></script> </body>错误Uncaught TypeError: Failed to execute 'getContext' on 'HTMLCanvasElement': 1 argument required, but only 0 present. at init (VM82 main.js:16) at game (VM82 main.js:11) init @ VM82 main.js:16 game @ VM82 main.js:11
- 2 回答
- 0 关注
- 2555 浏览
添加回答
举报
0/150
提交
取消