为什么我的海葵用sin 漂浮物用的cos才可以保持一致

/*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]);
    }


miracle__fu
浏览 1066回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5