I am not sure - do you mean "single line" like a circle, or a single
line as in straight one?
My idea was to test if a circle was inside a rectangle, so not sure if
would work with single lines...
It might not work very well with anything but a rectangle either.
On 16/06/2011 15:09, Paul Steven wrote:
Thanks Glen - this sounds like another good solution. I assume this would
work when the polygon is just a single line?
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Glen Pike
Sent: 16 June 2011 14:48
To: Flash Coders List
Subject: Re: [Flashcoders] Detecting if line crosses movie clip
Hi,
Can you measure the vector distance between the centre of the
polygon and the centre of the ball? If that is 0,0, and the diameter of
the circle is less than the smallest of width / height of the box, then
you are inside.
Glen
On 16/06/2011 13:58, Paul Steven wrote:
Working on a game where the player must draw around some colored balls on
screen by dragging the mouse to create the polygon that surrounds the
objects.
The polygon is created by drawing a series of lines every time the mouse
moves. If one of these lines intersects one of the balls (movie clip) I
need
to perform an action.
So my question is how to detect when the line intersects a movie clip?
The following is unsuitable as it treats the line as a rectangle e.g a
vertical line will have a lot of hit area that I do not want to be hit
area
if (ballMC.hitTestObject(lineMC)) {
My other best suggestion is to use the 4 lines that make up the bounding
box
of the ball movie clip and do a line intersection test for each line
against
the line being drawn. This seems overly complex so before I try this I
wanted to check there is not a simpler solution.
Thanks in advance
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
ca
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders