html5 canvas载入多张图片
letwih;letheh;document.body.style.overflow="hidden"letgam=document.getElementById('ga...
let wih;
let heh;
document.body.style.overflow = "hidden"
let gam = document.getElementById('game');
wih=window.innerWidth;
hih=window.innerHeight;
gam.width=wih;
gam.height=hih;
let game = gam.getContext('2d');
let cvb=new Image();
cvb.src="icon.png";
cvb.onload = function(){
game.drawImage(cvb, 0, 0, 1000, hih);
}
function chushi(){
let banban=new Image();
let beizi=new Image();
let dan=new Image();
let don=new Image();
let hutao=new Image();
let ji=new Image();
let kuai=new Image();
let mianbao=new Image();
let pin=new Image();
let qinpin=new Image();
let tang=new Image();
let tin=new Image();
let xia=new Image();
let xianjiao=new Image();
let xihon=new Image();
let xin=new Image();
let yin=new Image();
let yu=new Image();
let zha=new Image();
banban.src="images\banban.png";
beizi.src="images\beizi.png";
dan.src='images\dan.png';
don.src="images\don.png";
hutao.srcao="images\hutao.png";
ji.src="images\hutao.png";
kuai.src="images\kuai.png";
mianbao.src="images\mianbao.png";
pin.src="images\pin.png";
qinpin.src="images\qinpin.png";
tang.src="images\tang.png";
tin.src="images\tin.png";
xia.src="images\xia.png";
xianjiao.src="xianjiao\xianjiao.png";
xihon.src="images\xihon.png";
xin.src="images\xin.png";
yin.src="images\yin.png";
yu.src="images\yu.png";
zha.src="images\zha.png";
}
当载入很多图片时,为什么会连一张也绘画不出,只载入一张图片为什么就可以绘制出。
求解?求载入多张图片的方法?
求解?求载入多张图片的方法? 展开
let heh;
document.body.style.overflow = "hidden"
let gam = document.getElementById('game');
wih=window.innerWidth;
hih=window.innerHeight;
gam.width=wih;
gam.height=hih;
let game = gam.getContext('2d');
let cvb=new Image();
cvb.src="icon.png";
cvb.onload = function(){
game.drawImage(cvb, 0, 0, 1000, hih);
}
function chushi(){
let banban=new Image();
let beizi=new Image();
let dan=new Image();
let don=new Image();
let hutao=new Image();
let ji=new Image();
let kuai=new Image();
let mianbao=new Image();
let pin=new Image();
let qinpin=new Image();
let tang=new Image();
let tin=new Image();
let xia=new Image();
let xianjiao=new Image();
let xihon=new Image();
let xin=new Image();
let yin=new Image();
let yu=new Image();
let zha=new Image();
banban.src="images\banban.png";
beizi.src="images\beizi.png";
dan.src='images\dan.png';
don.src="images\don.png";
hutao.srcao="images\hutao.png";
ji.src="images\hutao.png";
kuai.src="images\kuai.png";
mianbao.src="images\mianbao.png";
pin.src="images\pin.png";
qinpin.src="images\qinpin.png";
tang.src="images\tang.png";
tin.src="images\tin.png";
xia.src="images\xia.png";
xianjiao.src="xianjiao\xianjiao.png";
xihon.src="images\xihon.png";
xin.src="images\xin.png";
yin.src="images\yin.png";
yu.src="images\yu.png";
zha.src="images\zha.png";
}
当载入很多图片时,为什么会连一张也绘画不出,只载入一张图片为什么就可以绘制出。
求解?求载入多张图片的方法?
求解?求载入多张图片的方法? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询