Multiple Touch Joints Single Body

I have searched high and low but cannot seem to find if this is even possible.

Starting with the MultiPuck example, I want to be able to “grab” the “puck” with 2 touch joints and rotate it around and or position it on the stage.

Think for example a plank on the stage that needs to be rotated and positioned with multi-touch to a specific angle and place on the stage.

The “began” phase of the touch event listener is only called once for the “puck”. I need it to be called once for each touch so I can create a new touch joint for each touch location on the same body.

You can check multiple touches.

This is exactly what I did using the MultiPuck as a base.

The second touch on the “disk” event phase “began” is never called so attaching the second temp joint to the “disk” cannot be created.

system.activate( “multitouch” )

disk:addEventListener( “touch”, dragBody ) – make object draggable

function dragBody( event, params )
local body = event.target
local phase = event.phase
local stage = display.getCurrentStage()

if “began” == phase then
stage:setFocus( body, event.id )
body.isFocus = true

-- drag the body from the point where it was touched
body.tempJoint = physics.newJoint( "touch", body, event.x, event.y )

I ended up creating 2 bodies and welding them together to get the 2 separate temp joints on the 2 different bodies to drag the single “plank” into position.

A suggestion would be to allow multiple “began” phases on a single body when multi-touch is enabled.

Thank you.

1 Like