2

Diagram: http://i.stack.imgur.com/gpL0P.png

Summary: How do I find the coordinates of the blue point in the diagram so I can calculate the positions of the red points adjacent to it and draw my triangle?

Details of problem: I am trying to make a tail on a drag-able tool-tip balloon for a map application I am making. I would like the the tail to be drawn from the location where the balloon is placed (point 0,0 of the sprite containing both balloon and tail) to the edge of the balloon, with the base of the tail always being the same arbitrary width width it connects to the balloon. The tail would be redrawn at the new coordinates every frame.

I would prefer not to hide part of the tail underneath the balloon, as I intend to use some transparency on it.

If the path were a circle or ellipse, I could use the angleToProgress method (along with some trig) of the CirclePath2D class of greensock's motion path library I could place a hidden path follower and get it's xy... However I am using a roundedRectangle... So I was thinking a better method would be some kind of collision detection between a line and wherever it crosses a path drawn around the perimeter of the balloon. However, I can't find any collision functions that return the xy of the collision.

So I'm stumped. I'm thinking what I want to do may not be easily doable in AS3 using the built in collision methods. Is there a collision library that will let me do this, or, perhaps preferably, some math that is eluding me? Because this seems like I'm over thinking it and it shouldn't be this hard.

[Note: I can't insert the diagram because I don't have enough reputation.]

4

1 に答える 1

1

青い交点が丸みを帯びた角の 1 つにある場合、どうしますか? それとは別に、それは非常に簡単に把握できるはずです-単純な線のジオメトリと結合のチェックを実行して、線がボックスの境界を形成する4つの無限線と交差する場所を確認し、実際にピタゴラスからの最初の交差点がどれであるかを判断できます行の長さ。

この方法を実行する場合は、バルーンのエッジに対する配置の位置を確認して、明らかに間違った (場合によっては存在しない) 交差の計算をスキップする必要があります (たとえば、バルーンの中心が配置のすぐ西にある場合)。ポイントの場合は、垂直線の交点の計算をスキップする必要があります)。実際、同様のロジックを使用して、ジオメトリに応じて 2 つまたは 3 つの側面をスキップできます。

于 2012-06-10T06:33:50.743 に答える