clearRect
先随便试验了一下效果,发现clearRect没有清除画布?什么情况?
var canvas = wx.createCanvas();
var ctx = canvas.getContext(‘2d’);
var ballX = 200;
function drawBall(ballX) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = “#fff”;
ctx.arc(ballX, 500, 10, 0, 2 * Math.PI);
ctx.fill();
}
setInterval(function () {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ballX-=10;
drawBall(ballX);
}, 500);