I’m testing out a simple physics scenario where two objects are joined by a “distance” joint… imagine a pendulum swinging on an anchor point. I would like to draw a single visible line between these objects, like the string that attaches them.
The problem I face is that the distance joint (by my own preference) is slightly elastic: it stretches just a bit as the pendulum swings faster. Thus, I can’t just create a physical “string” body and join one end to the anchor and the other end to the pendulum using pivot joints. That object would not be elastic, which basically defeats this approach.
Using “display.newLine” it’s easy enough to draw the initial line: just set vector point 1 as the X/Y of the anchor, vector point 2 as the X/Y of the pendulum. But as the pendulum swings, I can’t think of a simple way to move the line with it, ensuring that its length increases as the elastic distance joint increases too. I was hoping there was a method to simply re-position ONE point of the line (vector point 2) to a new position, but the documentation doesn’t seem to indicate this is possible.
One “solution” is to delete and re-draw the line every game cycle, but I imagine this would be very inefficient. Another possibility I considered is doing a constant rotation of the visible string object, but this again could tax the performance, because every single game cycle I’d need to calculate the angle between the anchor and the pendulum and then rotate the string accordingly. That’s alot of repeated calculation for one object, I’m guessing.
Any other ideas or suggestions?
Brent Sorrentino
Ignis Design [import]uid: 9747 topic_id: 17569 reply_id: 317569[/import]