Drag joints

Untitled.jpg?noCache=1412775970

drawing.jpg?noCache=1412776111

How to drag joints ?

local centerX = display.contentCenterX local centerY = display.contentCenterY local \_W = display.contentWidth local \_H = display.contentHeight local physics = require("physics") physics.start() physics.setDrawMode("hybrid") display.setStatusBar( display.HiddenStatusBar ) local background = display.newImage( "jungle\_bkg.png", centerX, centerY, true ) local b = display.newRect(20,150,20,50) physics.addBody(b,"static") local board = {} local joint = {} for j = 1,15 do board[j] = display.newRect(0,0,30,12) board[j].x = 20+ (j\*27) board[j].y = 150 board[j].myIndex = j -- for touch handler above physics.addBody( board[j], {density=2, friction=0.3, bounce=0.3 } ) -- damping the board motion increases the "tension" in the bridge board[j].angularDamping = 5000 board[j].linearDamping = 0.7 local myGroup = display.newGroup() myGroup:insert(board[j]) joint[j] = physics.newJoint( "pivot", b, board[j], 26+(j\*27), 150 ) end

Hi @leekaiwei92,

In your setup, you can’t really “drag” joints. You can only drag one of the objects that the joints are connecting. Also, pivot joints are not “stretchy” so it might not be ideal to use them for this scenario.

Have you fully explored the Physics Joints guide?

http://docs.coronalabs.com/guide/physics/physicsJoints/index.html

Take care,

Brent

Hi @leekaiwei92,

In your setup, you can’t really “drag” joints. You can only drag one of the objects that the joints are connecting. Also, pivot joints are not “stretchy” so it might not be ideal to use them for this scenario.

Have you fully explored the Physics Joints guide?

http://docs.coronalabs.com/guide/physics/physicsJoints/index.html

Take care,

Brent