首页 > 技术文章 > 鸟速度不匀速的方法Math.sqrt(this.i++); 开根号

oklfx 2018-01-20 11:31 原文

function Bird(imgArr, x, y){
this.imgArr = imgArr;
this.x = x;
this.y = y;
this.idx = parseInt(Math.random() * this.imgArr.length);
this.img = this.imgArr[this.idx];
// 定义一个变量用于记录鸟的位置
this.positionY = 0;
// 定义一个变量用于改变鸟的位置
this.i = 0;
}

 

Bird.prototype.fall = function(){
  this.positionY += Math.sqrt(this.i++);
};

推荐阅读