如何计算枪口坐标
How to calculate coordinates of the gunpoint
一天中的任何时间都很好!我有一些精灵:
A
点的坐标为 Actor.x; Actor.y
.
AB length = 96
BC length = 86
AC length = 42
All calculations are approximate, I made it with help the ruler in Photoshop.
Sprite 始终朝向鼠标,角度(以弧度为单位)存储在 Actor.direction
变量中。我用 0.3
.
比例绘制精灵
所有子弹都射向鼠标(即Bullet.direction == Actor.direction
)。我需要在 B
点创建项目符号。如何计算任意角度的 B
点的坐标?
UPD
如果我将在坐标中创建子弹:
x = Actor.x + 96 * math.cos(Actor.direction) * 0.3
y = Actor.y + 96 * math.sin(Actor.direction) * 0.3
我明白了:
请原谅我的英语不好!这不是我的母语。提前致谢!
让
cs = math.cos(Actor.direction)
sn = math.sin(Actor.direction)
B 点将从 A 偏移
dx = - 42 * sn + 86 * cs
dy = 42 * cs + 86 * sn
也许您需要在两个 42 秒之前更改符号
(我没算比例)
一天中的任何时间都很好!我有一些精灵:
A
点的坐标为 Actor.x; Actor.y
.
AB length = 96
BC length = 86
AC length = 42
All calculations are approximate, I made it with help the ruler in Photoshop.
Sprite 始终朝向鼠标,角度(以弧度为单位)存储在 Actor.direction
变量中。我用 0.3
.
所有子弹都射向鼠标(即Bullet.direction == Actor.direction
)。我需要在 B
点创建项目符号。如何计算任意角度的 B
点的坐标?
UPD
如果我将在坐标中创建子弹:
x = Actor.x + 96 * math.cos(Actor.direction) * 0.3
y = Actor.y + 96 * math.sin(Actor.direction) * 0.3
我明白了:
请原谅我的英语不好!这不是我的母语。提前致谢!
让
cs = math.cos(Actor.direction)
sn = math.sin(Actor.direction)
B 点将从 A 偏移
dx = - 42 * sn + 86 * cs
dy = 42 * cs + 86 * sn
也许您需要在两个 42 秒之前更改符号
(我没算比例)