Making a line that can move with two other objects?

Hi all,

I was wondering if anyone knows how to create a line between to objects. These two objects will then move staying about the same distance away from one another. However the objects will be at different angles. Is there anyway to make a line that will connect the two objects and move with them?

Thanks,
Chris Brasino [import]uid: 126017 topic_id: 32383 reply_id: 332383[/import]

Hi Chris,
There are two ways to accomplish this:

  1. you create a vector line between the objects (obvious). But since you can’t adjust this line on the fly by moving just one end point or the other, you need to constantly “update” the line using a Runtime listener in which you delete the previous line and draw a new line in its place, with the new one spanning the two objects. I’ve done this and performance seems fine.

  2. draw a line between them, then during the Runtime listener you check the angle between and distance between each object and rotate/scale/reposition the line accordingly. This involves a fair amount of math, so it might actually be slower than the above method.

One final note is that the vector line will be “jagged” (not anti-aliased) unless you specify otherwise in your config.lua. A line that’s an actual image will look smoother, but then you’d be stuck using method 2.

Brent [import]uid: 9747 topic_id: 32383 reply_id: 128851[/import]

Hi Chris,
There are two ways to accomplish this:

  1. you create a vector line between the objects (obvious). But since you can’t adjust this line on the fly by moving just one end point or the other, you need to constantly “update” the line using a Runtime listener in which you delete the previous line and draw a new line in its place, with the new one spanning the two objects. I’ve done this and performance seems fine.

  2. draw a line between them, then during the Runtime listener you check the angle between and distance between each object and rotate/scale/reposition the line accordingly. This involves a fair amount of math, so it might actually be slower than the above method.

One final note is that the vector line will be “jagged” (not anti-aliased) unless you specify otherwise in your config.lua. A line that’s an actual image will look smoother, but then you’d be stuck using method 2.

Brent [import]uid: 9747 topic_id: 32383 reply_id: 128851[/import]