/*main部分代码,定义了delta,在gameloop()中有如下代码*/delta += Math.PI * deltaTime * 0.0003;/*海葵部分代码*/ for(var i = 0; i < this.num; i++) { ctx2.beginPath(); ctx2.moveTo(this.x[i],canHeight); //ctx2.lineTo(this.x[i], canHeight-this.len[i]); var deltaX = Math.sin(delta);//[-1,1] //console.log("dust delta:"+delta); this.headX[i] = this.x[i] + deltaX * this.amp[i]; ctx2.quadraticCurveTo(this.x[i], canHeight - this.len[i] / 3, this.headX[i], canHeight - this.len[i]); //console.log("x1: " + this.x[i] + " y1: " + (canHeight - this.len[i] / 2) + " x2: " + (this.x[i] + deltaX) + " y2: " + (canHeight - this.len[i])); ctx2.stroke(); }/*漂浮物部分代码*/ var deltaX = Math.cos(delta);//[-1,1] //console.log("dust delta:"+delta); for(var i = 0; i < this.num; i++) { this.x[i] += deltaX * this.amp[i]; var id = this.dustCount[i]; ctx1.drawImage(this.img[id], this.x[i], this.y[i]); //console.log("img: "+ this.dustCount[i]); }
目前暂无任何回答
- 0 回答
- 0 关注
- 1065 浏览
添加回答
举报
0/150
提交
取消