我的怎么沒有效果呀?
<!DOCTYPE html>
<html>
<head>
? ? <meta charset="UTF-8">
? ? <title>javascript</title>
</head>
<body>
? ? <canvas id="canvas" style="border:1px solid #aaa;display:block;margin:50px auto;">
? ? ? ? 當前瀏覽器不支持Canvas,請更換瀏覽器后再試
? ? </canvas>
<script>
var ball={x:512,y:100,r=20,g:2,vx:-4.vy:0,color:"#005588"}
window.onload=funtion(){
? ? var canvas=document.getElementById('canvas');
? ? canvas.width=1024;
? ? canvas.height=768;
? ? var context=canvas.getContext("2d");
? ? setInterval(
? ? ? ? ?funtion(){
? ? ? ? ? ? render(context);
? ? ? ? ? ? update()
? ? ? ? ?},
? ? ? ? ?50
? ? ? ? )
}
function update(){
? ? ball.x +=ball.vx
? ? ball.y+=ball.vy
? ? ball.vy+=ball.g
}
funtion render(cxt){
? ? cxt.clearRect(0,0,cxt,canvas.width,canvas.height);
? ? cxt.fillStyle=ball.color
? ? cxt.arc(ball.x,ball.y,ball.r,0,2*Math.PI)
? ? cxt.fill()
}
</script>
<!--
? ? <script src="digit.js"></script>
? ? <script src="countdown.js"></script>
!-->
</body>
</html>
2016-07-24
這句代碼有問題,clearRect只包含了四個參數,不需要傳入畫布
至于其他的bug 我沒下載來看 ?所以要你自己fire Bug
2016-12-17
1,{x:512,y:100,r=20,g:2,vx:-4.vy:0,color:"#005588"}
2,funtion應為function