
1,html5中两张尺寸相同的图片,绘制的时候,第二张图片会将第一张覆盖掉,还是会重合 20
varcwidth=canvas.width;//获取画布的高度varcheight=canvas.height;//准备绘制开始时候的背景图片varimageba=ne...
var cwidth=canvas.width;
//获取画布的高度
var cheight=canvas.height;
//准备绘制开始时候的背景图片
var imageba=new Image();
imageba.src="images/splash_screen.jpg";
cxt.drawImage(imageba,0,0,cwidth,cheight);
var imageba=new Image();
imageba.src="images/title.jpg";
cxt.drawImage(imageba,0,0,cwidth,cheight);
两张图片会覆盖还是重叠呢
另外
//准备绘制开始时候的背景图片
var imageba=new Image();
imageba.src="images/splash_screen.jpg";
imageba.onload=function(){
cxt.drawImage(imageba,0,0,cwidth,cheight);
}
//显示游戏的说明文字
cxt.fillStyle="red";
cxt.font="20px 楷体";
cxt.fillText("方向键移动",360,310,100);
cxt.fillText("空格键键射击",360,340,100);
这样为啥文字就看不见了,而去掉onload就行了,求指导。。。。 展开
//获取画布的高度
var cheight=canvas.height;
//准备绘制开始时候的背景图片
var imageba=new Image();
imageba.src="images/splash_screen.jpg";
cxt.drawImage(imageba,0,0,cwidth,cheight);
var imageba=new Image();
imageba.src="images/title.jpg";
cxt.drawImage(imageba,0,0,cwidth,cheight);
两张图片会覆盖还是重叠呢
另外
//准备绘制开始时候的背景图片
var imageba=new Image();
imageba.src="images/splash_screen.jpg";
imageba.onload=function(){
cxt.drawImage(imageba,0,0,cwidth,cheight);
}
//显示游戏的说明文字
cxt.fillStyle="red";
cxt.font="20px 楷体";
cxt.fillText("方向键移动",360,310,100);
cxt.fillText("空格键键射击",360,340,100);
这样为啥文字就看不见了,而去掉onload就行了,求指导。。。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询