Most people would start with the rope by taking the chains sample in Corona sample code and modifying it to make the segments short newRect’s. At least I did. The resulting “rope” is stiff and a bit unrealistic, and very persnickety in what it can hold without stretching/breaking. So - some hints to make the rope smooth as butter:
-
Call physics.setContinuous( false ) right after physics.start(). This makes the joints behavior MUCH more reasonable.
-
Make the rope segments overlap a little - by 2 pixels or so.
-
Make each rope segment a sensor - add isSensor=true to your addBody parameters. This would make it so your other objects cannot collide with ropes, but then you probably didn’t want them to anyway. The important part here is that the segments don’t “collide” with each other.
-
Make rope segments’ density relatively high compared to things it holds.
-
Make sure that the joints are set in the middle of the rope segment (that is, if its thickness is 3, that the joint is in the middle pixel of the 3). Otherwise the physics would cause it to favor one side over the other when it bends.
-
Modify the rope’s “stiffness” by setting the joints’ rotation limits. I use:
[lua]J.isLimitEnabled = true
J:setRotationLimits( -35, 35 )[/lua]
for a fairly “loose” rope.
Enjoy. [import]uid: 160496 topic_id: 29761 reply_id: 329761[/import]