2017-06-02 50 views
0

一天中的好時光!我有一些精靈:如何計算槍口的座標

enter image description here

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. 

精靈總是朝向鼠標,角度(以弧度爲單位)在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 

我明白了:

enter image description here

原諒我的英語不好!這不是我的母語。先謝謝你!

回答

1

cs = math.cos(Actor.direction) 
sn = math.sin(Actor.direction) 

B點將從由

dx = - 42 * sn + 86 * cs 
dy = 42 * cs + 86 * sn 

轉移也許你會需要兩個42S

前改變的跡象(我沒有考慮規模)

+0

非常感謝! – Eanmos