Hey all, the title pretty much explains exactly what I’m trying to do. This is what I have so far:
function spawnRagdoll(event)
if event.phase == "ended" then
ragdollGroup = display.newGroup()
ragdollBody = display.newImage("Art/ragdollBody.png")
ragdollArm1 = display.newImage("Art/ragdollArm.png")
ragdollArm2 = display.newImage("Art/ragdollArm.png")
physics.addBody(ragdollBody, {friction = 0.3})
physics.addBody(ragdollArm1, {friction = 0.3})
physics.addBody(ragdollArm2, {friction = 0.3})
physics.newJoint("pivot", ragdollBody, ragdollArm1, 28, 12)
physics.newJoint("pivot", ragdollBody, ragdollArm2, 0, 12)
ragdollGroup:insert(ragdollBody)
ragdollGroup:insert(ragdollArm1)
ragdollGroup:insert(ragdollArm2)
ragdollGroup.y = 430
local x = event.x
local y = event.y
local xForce = x - ragdollBody.x
local yForce = y - ragdollBody.y
ragdollBody:applyLinearImpulse(xForce, yForce, ragdollBody.x, ragdollBody.y)
end
end
Runtime:addEventListener("touch", spawnRagdoll)
This works, sort of…It fires in the general direction of the touch position, but only if I touch right at the top edge of the screen. Also, I’m only using the simulator right now. Tomorrow, I’ll probably get around to testing this on a real device. Thanks for any help, guys! [import]uid: 13174 topic_id: 5366 reply_id: 305366[/import]