AS3改变线曲线

时间:2013-08-07 22:48:09

标签: actionscript-3 line curve

我有我的代码的这一部分,我只需要弯曲相反的直接。 它会创建一条从点到鼠标的线条。我需要它向下弯曲。 我会改变什么价值来做这件事?

    if ((mouseX-targetPointX<0 && mouseY-targetPointY>0) || (mouseX-targetPointX>=0 && mouseY-targetPointY<=0))
    {
        if (mouseY-targetPointY>0)
        {
            line.moveTo(mouseX-offset,mouseY-offset);
            line.curveTo(mouseX-offset,targetPointY-offset,targetPointX-offset,targetPointY-offset);
            line.lineTo(targetPointX+offset,targetPointY+offset);
            line.curveTo(mouseX+offset,targetPointY+offset,mouseX+offset,mouseY+offset);
        }
        else
        {
            line.moveTo(mouseX-offset,mouseY-offset);
            line.curveTo(targetPointX-offset,mouseY-offset,targetPointX-offset,targetPointY-offset);
            line.lineTo(targetPointX+offset,targetPointY+offset);
            line.curveTo(targetPointX+offset,mouseY+offset,mouseX+offset,mouseY+offset);
        }
    }
    else
    {
        if (mouseX<targetPointX && mouseY<targetPointY)
        {

            line.moveTo(mouseX-offset,mouseY+offset);
            line.curveTo(targetPointX-offset,mouseY+offset,targetPointX-offset,targetPointY+offset);
            line.lineTo(targetPointX+offset,targetPointY-offset);
            line.curveTo(targetPointX+offset,mouseY-offset,mouseX+offset,mouseY-offset);
        }
        else
        {
            line.moveTo(mouseX-offset,mouseY+offset);
            line.curveTo(mouseX-offset,targetPointY+offset,targetPointX-offset,targetPointY+offset);
            line.lineTo(targetPointX+offset,targetPointY-offset);
            line.curveTo(mouseX+offset,targetPointY-offset,mouseX+offset,mouseY-offset);
        }
    }
    line.endFill();
}

}

1 个答案:

答案 0 :(得分:0)

您需要更改curveTo方法中的控制点,这是前2个参数。

curveTo(controlPointX,controlPointY,targetX,targetY);

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html#curveTo()