okay thanks 30below!! I am not trying to do anything too fancy with it… just want it for looks… when you drag the doll around on the screen it will look as if you are dragging a real doll… I was able to connect all the body parts to the doll. I am just running into one small issue… The legs are too stiff… I want them to spread apart and do a split when they land on the ground… Here is my code
[lua]local physics = require(“physics”)
physics.start()
physics.setGravity(0,10)
physics.setDrawMode(“hybrid”)
– values
local props = { friction=1, density=1, bounce=0.1 }
local doll = display.newGroup()
local scene = display.newGroup()
– scene
scene.floor = display.newRect ( scene, 0, 400, 1024, 10 )
scene.topWall = display.newRect ( scene, 0, 0, 1024, 10 )
scene.leftWall = display.newRect ( scene, 0, 5, 10, 1020 )
scene.rightWall = display.newRect ( scene, 1015, 5, 10, 1020 )
physics.addBody( scene.floor, “static”, props )
physics.addBody( scene.topWall, “static”, props )
physics.addBody( scene.leftWall, “static”, props )
physics.addBody( scene.rightWall, “static”, props )
local doll_head = display.newImageRect(doll, “dollHead.png”, 128,79)
doll_head.x = 150; doll_head.y = 60
physics.addBody(doll_head,“dynamic”,{ friction=1, density=1, bounce=0.1, radius=20 })
local doll_body = display.newImageRect(doll, “dollBody.png”, 113,94)
doll_body.x = doll_head.x
doll_body.y = doll_head.y + 65
physics.addBody(doll_body,“dynamic”,props)
local doll_leftArm = display.newImageRect(doll, “dollleftArm.png”, 55,33)
doll_leftArm.x = doll_body.x - 55
doll_leftArm.y = doll_body.y -15
physics.addBody(doll_leftArm,“dynamic”,props)
local doll_rightArm = display.newImageRect(doll, “dollrightArm.png”, 65,33)
doll_rightArm.x = doll_body.x + 50
doll_rightArm.y = doll_body.y - 15
physics.addBody(doll_rightArm,“dynamic”,props)
local doll_leftLeg = display.newImageRect(doll, “dollleftLeg.png”, 32,68)
doll_leftLeg.x = doll_body.x
doll_leftLeg.y = doll_body.y + 55
physics.addBody(doll_leftLeg,“dynamic”,props)
local doll_rightLeg = display.newImageRect(doll, “dollrightLeg.png”, 36,68)
doll_rightLeg.x = doll_body.x + 20
doll_rightLeg.y = doll_body.y + 55
physics.addBody(doll_rightLeg,“dynamic”,props)
local doll_rightShoe = display.newImageRect(doll, “dollrightShoe.png”, 36,30)
doll_rightShoe.x = doll_rightLeg.x
doll_rightShoe.y = doll_rightShoe.y +218
physics.addBody(doll_rightShoe,“dynamic”,props)
local doll_leftShoe = display.newImageRect(doll, “dollrightShoe.png”, 36,25)
doll_leftShoe.x = doll_leftLeg.x - 5
doll_leftShoe.y = doll_leftShoe.y + 218
physics.addBody(doll_leftShoe,“dynamic”,props)
doll:insert(doll_head)
doll:insert(doll_leftArm)
doll:insert(doll_rightArm)
doll:insert(doll_rightShoe)
doll:insert(doll_leftShoe)
doll:insert(doll_leftLeg)
doll:insert(doll_rightLeg)
doll:insert(doll_body)
doll_head_joint = physics.newJoint(“pivot”, doll_head, doll_body, doll_head.x, doll_head.y + doll_head.height*0.5)
doll_leftArm_joint = physics.newJoint(“pivot”, doll_leftArm, doll_body, doll_body.x + 30, doll_body.y - 40)
doll_rightArm_joint = physics.newJoint(“pivot”, doll_rightArm, doll_body, doll_body.x + 30, doll_body.y - 40)
doll_leftLeg_joint = physics.newJoint(“pivot”, doll_leftLeg, doll_body, doll_body.x + 30, doll_body.y - 40)
doll_rightLeg_joint = physics.newJoint(“pivot”, doll_rightLeg, doll_body, doll_body.x + 30, doll_body.y - 40)
doll_rightShoe_joint = physics.newJoint(“weld”, doll_rightShoe, doll_rightLeg, doll_rightLeg.x + 30, doll_rightLeg.y - 40)
doll_leftShoe_joint = physics.newJoint(“weld”, doll_leftShoe, doll_leftLeg, doll_leftLeg.x + 30, doll_leftLeg.y - 40)
function addRotationLimits( joints, limit )
for i=1, #joints do
local joint = joints[i]
joint.isLimitEnabled = true
joint:setRotationLimits( -limit, limit )
end
end
function addRotationLimits2( joints, limit )
for i=1, #joints do
local joint = joints[i]
joint.isLimitEnabled = true
joint:setRotationLimits( -limit, limit )
end
end
function addRotationLimits3( joints, limit )
for i=1, #joints do
local joint = joints[i]
joint.isLimitEnabled = true
joint:setRotationLimits( -limit, limit )
end
end
addRotationLimits(
{ doll_head_joint },
45
)
addRotationLimits2(
{ doll_leftArm_joint, doll_rightArm_joint},
5
)
addRotationLimits3(
{ doll_leftLeg_joint, doll_rightLeg_joint },
10
)
function touch( event )
print(“touch”)
if (event.phase == ‘began’) then
doll.touch = physics.newJoint( “touch”, event.target, event.x, event.y )
print(doll.touch.maxForce,doll.touch.frequency,doll.touch.dampingRatio)
doll.touch:setTarget( event.x, event.y )
display.getCurrentStage():setFocus( event.target )
elseif (event.phase == ‘moved’ and doll.touch ~= nil) then
doll.touch:setTarget( event.x, event.y )
elseif (doll.touch ~= nil) then
doll.touch:removeSelf()
doll.touch = nil
display.getCurrentStage():setFocus( nil )
end
return true
end
function addTouch( dg )
for i=1, dg.numChildren do
dg[i]:addEventListener( “touch”, touch )
end
end
addTouch( doll )[/lua]
THANKS!! [import]uid: 51459 topic_id: 22624 reply_id: 90249[/import]