消失的小球(鼠标按下随机弹出小球)

Ball.prototype.move = function () { this.x = this.speedX; this.y = this.speedY; // 边界判断 if (this.x - this.r <= 0 || this.x this.r >= cv.offsetWidth) { this.speedX *= -1; } if (this.y - this.r <= 0 || this.y this.r >= cv.offsetHeight) { this.speedY *= -1; } // 开始绘制 ctx.beginPath(); // 设置颜色 ctx.fillStyle = this.bg; ctx.arc(this.x,this.y,this.r,0,Math.PI*2); ctx.fill(); }