1. 首页
  2. 编程语言
  3. Web开发
  4. 消失的小球(鼠标按下随机弹出小球)

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

上传者: 2022-07-08 00:38:06上传 .HTML文件 2.96 KB 热度 11次

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(); }

下载地址
用户评论