Graphics画扇形的实现方法

游戏中需要画扇形功能,纪录一下 == Graphics 画扇形 ==

代码

function test() {
		this.Graphics.clear();
		let r = 100 //半径
		let startRadians = -0.25*Math.PI; //起始角度
		let endRadian = 0.25*Math.PI;//结束角度
		let start = cc.v2(100, 100); //圆心点
        let point1 = cc.v2(Math.cos(startRadians)*r + start.x, Math.sin(startRadians)*r + start.y)
        let point2 = cc.v2(Math.cos(endRadian)*r + start.x, Math.sin(endRadian)*r + start.y)
        
		//画扇形的三角区域
        this.Graphics.moveTo(start.x, start.y);
        this.Graphics.lineTo(point1.x, point1.y);
        this.Graphics.lineTo(point2.x, point2.y);
        this.Graphics.lineTo(start.x, start.y); 
		
		//画扇形的圆弧区域
        this.Graphics.arc(start.x, start.y, r, startRadians, endRadian, true)
        this.Graphics.fill();
}

End

有其他更好的方法请留言,感谢

point2可以不用计算。

        this.Graphics.moveTo(start.x, start.y);
        this.Graphics.lineTo(point1.x, point1.y);
        this.Graphics.arc(start.x, start.y, r, startRadians, endRadian, true)
        this.Graphics.lineTo(start.x, start.y); 
        this.Graphics.fill();

或者用Sprite的filled模式来模拟。

:ok_hand:,thank

大佬 求问 感觉逆时针和顺时针是反过来的

这个不是控制逆时针和顺时针的吗

我这边问题是 0-0.25的时候 image 应该旋转的是 3点钟方向顺时针45度吗 但是现在填充位置不对