第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

wsm將畫背景的函數(shù)放在init中就不會(huì)顯示背景圖畫?

function?game()?{
	//?body...
	init();
	lasttime?=?Date.now();
	delttime?=?0;
	game_loop();
}
function?init?()?{
	//獲得canvas?contex
	//canvas1?用來處理魚,土壤,UI,圓圈
	can1?=?document.getElementById("canvas1");
	//canvas2?用來處理背景????	can2?=?document.getElementById("canvas2");
	ctx1?=?can1.getContext('2d');
	ctx2?=?can2.getContext('2d');
	bgPic.src="../SRC/bg.jpg";//文件路徑
	canWidth?=?can2.width;
	canHight?=?can2.height;
	dram_image();
}
function?game_loop?()?{
	//?body...比如魚的游動(dòng)
	//該函數(shù)要對(duì)瀏覽器適配
	requestAnimFrame(game_loop);//比setTimeout?setInterval?科學(xué)?這個(gè)是根機(jī)器性能有關(guān)
	//console.log("game");
	var?now?=?Date.now();
	delttime?=?now?-?lasttime;
	lasttime?=?now;
}
/*畫canvas背景*/
function?dram_image?(){
	console.log(canHight,canWidth,bgPic);
	ctx2.drawImage(bgPic,0,0,canWidth,canHight);
}


正在回答

2 回答

寫成這樣在init里面調(diào)用就行了

function drawBackground() {

????bgPic.onload=function(){

????????ctx2.drawImage(bgPic,0,0,canWidth,canHeight);

????}

}


1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕仙837676

這樣寫不報(bào)錯(cuò),但是背景還是出不來
2018-12-28 回復(fù) 有任何疑惑可以回復(fù)我~
#2

慕仙837676 回復(fù) 慕仙837676

在 function drawBackground() { bgPic.onload=function(){ ctx2.drawImage(bgPic,0,0,canWidth,canHeight); console,log("canwWidth"); } } 控制臺(tái)也沒有反應(yīng)
2018-12-28 回復(fù) 有任何疑惑可以回復(fù)我~

同問,,,

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

wsm將畫背景的函數(shù)放在init中就不會(huì)顯示背景圖畫?

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)