如何获得 Phaser3 精灵顶部的坐标?

How can I get a coordinate of the top side of a Phaser3 sprite?

我想找出片段的顶部坐标。这个想法是在一个点和绿色元素的顶部之间画一条线。

如何找到或计算这个坐标。我知道盒子的大小和角度。

这里是 source code 我创建一条紫色线的地方。

这是一个 gif 示例。

谢谢!

据我了解,旋转中心cx, cy应该在绳子的顶端。

网络顶点有坐标

tx = cx + ropelen * Cos(angle)
ty = cy + ropelen * Sin(angle)

如果精灵的基点与顶点不同,但在dy下方,您可以使用ropelen + dy

通过相同的公式找到它的坐标

如果精灵的基点与顶点不同,但在dx的左侧,您可以使用相同的公式使用sqrt(ropelen^2 + dx^2)和角度angle + atan(dx/ropelen)[=找到它的坐标17=]