2 Ropes on the ball

hello :slight_smile:
i am trying to make 2 ropes grabbing a ball, i saw the rope tutorial that have 1 rope grabbing the ball, i create a secound rope but cant grab the same ball that rope1 is grabbing.
the code ir here, if anyone can help, i would be grateful

dont need config.lua or other source, just this

[code]

display.setStatusBar (display.HiddenStatusBar)

display.newImage(“bg.jpg”);

–> Start Physics
local physics = require (“physics”)
physics.start ()
physics.setGravity (0, 10)

–physics.setDrawMode (“hybrid”)

–> Create Walls
local leftWall = display.newRect (0, 0, 1, display.contentHeight)
local rightWall = display.newRect (display.contentWidth, 0, 1, display.contentHeight)
local ceiling = display.newRect (0, 0, display.contentWidth, 1)
local floor = display.newRect (0, display.contentHeight, display.contentWidth, 1)

physics.addBody (leftWall, “static”, {bounce = 0.0, friction = 10})
physics.addBody (rightWall, “static”, {bounce = 0.0, friction = 10})
physics.addBody (ceiling, “static”, {bounce = 0.0, friction = 10})
physics.addBody (floor, “static”, {bounce = 0.0, friction = 10})

local xCenter = 160
local wCeil = 120
local hCeil = -5
–local ceiling = display.newRect( xCenter - wCeil*0.5, 0, wCeil, hCeil )
physics.addBody( ceiling, “static”, { density=0, friction=0.5,bounce=0.2 } )

local prevBody = ceiling
local prevBody1 = ceiling

local w,h = 10,10
local halfW,halfH = 0.5*w,0.5*h

– center of body
local x = xCenter
local y = hCeil - halfH
local yJoint = y - halfH

– rope
for i = 1, 30 do
y = y + h
yJoint = yJoint + h

local body = display.newImage(“rope.png” ,x-halfW, y-halfH) --) display.newRect( x-halfW, y-halfH, w, h )
local body1 = display.newImage(“rope.png” ,x-halfW, y-halfH)
physics.addBody( body, { density=15, friction=0.5, bounce = .2 })
physics.addBody( body1, { density=15, friction=0.5, bounce = .2 })

local joint = physics.newJoint( “pivot”, prevBody, body, xCenter, yJoint )
local joint = physics.newJoint( “pivot”, prevBody1, body1, xCenter, yJoint )

prevBody = body
prevBody1 = body1
end

– final body

local body = display.newImage(“soccerball.png”, x,y -30); – display.newCircle( x, y, r )
local r = body.height *0.5
physics.addBody( body, { density=2, friction=0.5, bounce=.2, radius=r })
local joint = physics.newJoint( “pivot”, prevBody, body, xCenter, y )
physics.addBody( body1, { density=2, friction=0.5, bounce=.2, radius=r })
local joint = physics.newJoint( “pivot”, prevBody1, body1, xCenter, y )
local ball = body
[import]uid: 26056 topic_id: 14998 reply_id: 314998[/import]

Modified from your example (this works):

[code]

display.setStatusBar (display.HiddenStatusBar)

–> Start Physics
local physics = require (“physics”)
physics.start ()
physics.setGravity (0, 10)

–physics.setDrawMode (“hybrid”)

–> Create Walls
local leftWall = display.newRect (0, 0, 1, display.contentHeight)
local rightWall = display.newRect (display.contentWidth, 0, 1, display.contentHeight)
local ceiling = display.newRect (0, 0, display.contentWidth, 1)
local floor = display.newRect (0, display.contentHeight, display.contentWidth, 1)

physics.addBody (leftWall, “static”, {bounce = 0.0, friction = 10})
physics.addBody (rightWall, “static”, {bounce = 0.0, friction = 10})
physics.addBody (ceiling, “static”, {bounce = 0.0, friction = 10})
physics.addBody (floor, “static”, {bounce = 0.0, friction = 10})

local xCenter = 160
local wCeil = 120
local hCeil = -5

local prevBody = ceiling
local prevBody1 = ceiling

local w,h = 10,10
local halfW,halfH = 0.5*w,0.5*h

– center of body
local x = xCenter
local y = hCeil - halfH
local yJoint = y - halfH

– rope
for i = 1, 30 do
y = y + h
yJoint = yJoint + h

local body = display.newRect( x-halfW, y-halfH, w, h )
local body1 = display.newRect( x-halfW, y-halfH, w, h )

physics.addBody( body, { density=15, friction=0.5, bounce = .2 })
physics.addBody( body1, { density=15, friction=0.5, bounce = .2 })

local joint = physics.newJoint( “pivot”, prevBody, body, xCenter, yJoint )
local joint2 = physics.newJoint( “pivot”, prevBody1, body1, xCenter, yJoint )

prevBody = body
prevBody1 = body1
end

– final body

local body = display.newCircle( x, y, -30 )
local r = body.height *0.5

physics.addBody( body, { density=2, friction=0.5, bounce=.2, radius=r })

body:applyLinearImpulse(200, 0, body.x, body.y)

local joint = physics.newJoint( “pivot”, prevBody, body, xCenter, y )
local joint2 = physics.newJoint( “pivot”, prevBody1, body, xCenter, y )
[/code] [import]uid: 84637 topic_id: 14998 reply_id: 55374[/import]

Thank You very much :slight_smile:
I just need one more help for now, if possible, because I have this doubt for some time and cant solve it :confused:

is on the link: i need: when i touch on the slider image it change the scene, i have all code and all is perfect, but need this point

http://developer.anscamobile.com/forum/2011/09/08/slider-touch-event [import]uid: 26056 topic_id: 14998 reply_id: 55378[/import]