課程
/前端開(kāi)發(fā)
/HTML/CSS
/HTML5小游戲---愛(ài)心魚(yú)(上)
?Cannot set property 'onload' of null",是怎么回事?
2016-09-18
源自:HTML5小游戲---愛(ài)心魚(yú)(上)
正在回答
js代碼引用要在canvas標(biāo)簽下面
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);
舉報(bào)
學(xué)做HTML5游戲,輕輕松松帶你上手,適合剛?cè)胧钟螒蜷_(kāi)發(fā)的同學(xué)
1 回答ncaught TypeError: Cannot read property 'offSetX' of undefined
1 回答Uncaught TypeError: Cannot read property 'offsetX' of undefined一直錯(cuò)啊。。求求求解
1 回答為什么我在gameloop()方法里面寫(xiě)ane.draw();報(bào)錯(cuò)Uncaught TypeError: Cannot read property 'draw' of undefined,幫忙給個(gè)解答,謝謝
1 回答1:29秒那里 如何看ONLOAD的?
2 回答在進(jìn)行g(shù)ame函數(shù)調(diào)試時(shí),我的onload沒(méi)有在瀏覽器中顯示出來(lái),這是怎么回事?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢(xún)優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-05-14
js代碼引用要在canvas標(biāo)簽下面
2016-09-18
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);
}