Cannot set property 'onload' of null",是怎么回事?
js代码引用要在canvas标签下面
document.body.onload = game;
function game(){
//初始工作
init();
}
function init(){
//获得canvas、context
var can1 = document.getElementById("canvas1");//在前面:fishes、UI、dust、circle
var ctx1 = can1.getContext();
var can2 = document.getElementById("canvas2");//background、ane、fruits
var ctx2 = can2.getContext();
}
function gameloop(){
requestAnimFrame(gameloop);
}