app collisions

My name is Brandon and im new to corona and i was starting out on my first app i wanted to start out with the chains sample and change some stuff around so thats where i am. but i dont know how to get my ball to collide with the target and say you win next level or something like that can you guys please help here is my main.lua file.

local physics = require(“physics”)
physics.start()

physics.setScale( 60 )

display.setStatusBar( display.HiddenStatusBar )

– The final “true” parameter overrides Corona’s auto-scaling of large images
local background = display.newImage( “grille_bkg.png”, 0, 0, true )

local ground = display.newImage( “ground.png”, 0, 420, true )
physics.addBody( ground, “static”, { friction=0.5 } )

local beam1 = display.newImage( “beam.png” )
beam1.x = 20; beam1.y = 350; beam1.rotation = -40
physics.addBody( beam1, “static”, { friction=0.5 } )

local beam2 = display.newImage( “beam.png” )
beam2.x = 410; beam2.y = 340; beam2.rotation = 20
physics.addBody( beam2, “static”, { friction=0.5 } )

local beam3 = display.newImage( “beam_long.png” )
beam3.x = 280; beam3.y = 50
physics.addBody( beam3, “static”, { friction=0.5 } )

local target1 = display.newImage( “033_target1.png” )
target1.x = 280; target1.y = 400
physics.addBody( target1, “static”, { friction=0.5 } )

local myJoints = {}

for i = 1,5 do
local link = {}
for j = 1,17 do
link[j] = display.newImage( “link.png” )
link[j].x = 121 + (i*34)
link[j].y = 55 + (j*17)
physics.addBody( link[j], { density=2.0, friction=0, bounce=0 } )

– Create joints between links
if (j > 1) then
prevLink = link[j-1] – each link is joined with the one above it
else
prevLink = beam3 – top link is joined to overhanging beam
end
myJoints[#myJoints + 1] = physics.newJoint( “pivot”, prevLink, link[j], 121 + (i*34), 46 + (j*17) )

end
end

local randomBall = function()
ball = display.newImage( “super_ball.png” )
ball.x = math.touch

physics.addBody( ball, { density=2.9, friction=0.5, bounce=0.7, radius=24 } )
end

– Call the above function 12 times
timer.performWithDelay( 2500, randomBall, 1 )

[import]uid: 46536 topic_id: 12930 reply_id: 312930[/import]

Please read the rules before posting again; without your code in proper tags it is not going to get read. (Too much of a headache.)

For what you want to do you should check out this physics collision tutorial.

It should do the trick :slight_smile: [import]uid: 52491 topic_id: 12930 reply_id: 47460[/import]

oh sorry about that. [import]uid: 46536 topic_id: 12930 reply_id: 47467[/import]