【发布时间】:2021-02-27 17:16:10
【问题描述】:
我试图创建这些移动的形状,形状由半圆和对称的上弧和下弧组成。 它们应该只是前面的形状,但现在它们移动时有一条像尾巴一样拖在后面的线。 The output shape with unknown tail
似乎这些线来自上下弧的 moveTo 部分,但我不知道如何解决它。 我应该在哪里改变以摆脱它?
function Fish(x, y, dx, dy, radius){
this.x = x;
this.y = y;
this.dx = dx;
this.dy = dy;
this.radius = 30;
this.draw = function(){
c.beginPath();
c.arc(this.x/0.6, this.y, this.radius, Math.PI * 1.5, Math.PI * 0.5, false)
//Upper Arc
c.moveTo(this.x, this.y);
c.arc(this.x/0.6, this.y+(3*this.radius), this.radius*4, Math.PI * 229/180, Math.PI * 1.5, false)
//Lower Arc
c.moveTo(this.x, this.y);
c.arc(this.x/0.6, this.y-(3*this.radius), this.radius*4, Math.PI * 131/180 , Math.PI * 0.5, true)
c.strokeStyle = "green";
c.stroke();
}
【问题讨论】:
标签: javascript html animation canvas