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

如果蓝色的交点在圆角之一上,你会怎么做?除此之外,它应该很容易弄清楚 - 您可以进行简单的线几何和键检查,以查看线与构成框边界的四条无限线相交的位置,然后确定哪个实际上是勾股算式的第一个交点线长。

如果您使用此方法,则需要检查放置相对于气球边缘的位置,以跳过计算明显错误(有时不存在)的交叉点(例如,如果气球中心直接位于放置的西边点,那么你应该跳过计算垂直线的交点)。事实上,您可以使用类似的逻辑来跳过 2 或 3 条边,具体取决于几何形状。

于 2012-06-10T06:33:50.743 回答