I’d like to draw distance joints (without setting the physics drawMode to “debug” or “hybrid”).
What I am doing right now is maintaining a joints-and-hints table:
physics.pause()
local joints = {}
function join(b1, b2)
local j = physics.newJoint( "distance", b1, b2, b1.x, b1.y, b2.x, b2.y)
local l = display.newLine(b1.x,b1.y, b2.x, b2.y)
l.width = 8
l:setColor(255,255,255)
joints[#joints+1] = {joint=j, hint=l, body1=b1, body2=b2}
end
Now, I’d like to update the hints for these joints while physics is playing. So, figuring I can tap into enterFrame events, I set up a listener just for that purpose:
...
Runtime:addEventListener("enterFrame", updateJointHints)
function updateJointHints()
for i=1,#joints do
joints[i].hint.x = joints[i].body1.x
joints[i].hint.y = joints[i].body1.y
-- HOW DO I DO THIS? access hint's 2nd vertex so that I can update its position?
end
end
Question: how do I access a display line’s nth vertex?
Thanks
Alex
[import]uid: 3473 topic_id: 2328 reply_id: 302328[/import]