canvas画图片显示不出来,代码如下。 5
<!DOCTYPEhtml><html><head><metacharset="utf-8"/><title>playGame</title></head><body><...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>playGame</title>
</head>
<body>
<canvas id="MyCanvas" width="740px" height="500px"></canvas>
<script type="text/javascript">
var c=document.getElementById("MyCanvas");
var cxt=c.getContext("2d");
//draw backgroundimage
function drawbg(){
var bgimg= new image();
bgimg.src="img/bgimg.jpg";
cxt.drawImage(bgimg,0,0);
}
drawbg();
setInterval(drawbg,200);
</script>
</body>
</html> 展开
<html>
<head>
<meta charset="utf-8" />
<title>playGame</title>
</head>
<body>
<canvas id="MyCanvas" width="740px" height="500px"></canvas>
<script type="text/javascript">
var c=document.getElementById("MyCanvas");
var cxt=c.getContext("2d");
//draw backgroundimage
function drawbg(){
var bgimg= new image();
bgimg.src="img/bgimg.jpg";
cxt.drawImage(bgimg,0,0);
}
drawbg();
setInterval(drawbg,200);
</script>
</body>
</html> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询