问题描述
单击按钮时,我试图在X轴上移动一个蓝色方块。 当我按下按钮时,什么也没有发生。我不知道我在做什么错。
代码如下:
<html>
<head>
<canvas id="myCanvas" width="600" height="600"></canvas>
<title>tilte</title>
</head>
<body>
<button onclick="draw">/button>
<script>
onload = function() {
var canvas = document.getElementById("myCanvas")
var ctx = canvas.getContext("2d")
var recX = 250
var recY = 500
var speedX = 5;
draw()
move()
function draw() {
ctx.fillStyle = "red"
ctx.fillRect(0,600,600)
ctx.fillStyle = "blue"
ctx.fillRect(recX,recY,50,50)
}
}
</script>
</body>
</html>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)