physics.addBody error

I am trying to get an app that will create a ball and it will bounce across the screen as you drag over it.
Here is my function.

local function spawnBall( event )
local phase = event.phase
if “ended” == phase then
myLabel.isVisible = false

physics.addBody( ball, { density = 1.0, friction = 0.3, bounce = 0.2, radius = 25 } ) ball.linearDamping = 0.4
ball.angularDamping = 0.6

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

Runtime error
/Users/andrew/Dropbox/Manual Bouncing Ball/main.lua:56: ERROR: table expected. If this is a function call, you might have used ‘.’ instead of ‘:’
stack traceback:
[C]: ?
[C]: in function ‘addBody’
/Users/andrew/Dropbox/Manual Bouncing Ball/main.lua:56: in function
?: in function <?:214>
Line 50 is the introduction local function spawnBall
Line 56 is physics.addBody

Any help will be appreciated I am stuck.
[import]uid: 41573 topic_id: 7246 reply_id: 307246[/import]

Hello andrew.weeks,

In the line of addBody, you have 2 sentences. If this is true, you need to separate with a “;” or split into 2 lines

[lua]Original:
physics.addBody( ball, { density = 1.0, friction = 0.3, bounce = 0.2, radius = 25 } ) ball.linearDamping = 0.4

Change:
physics.addBody( ball, { density = 1.0, friction = 0.3, bounce = 0.2, radius = 25 } ); ball.linearDamping = 0.4

Or:
physics.addBody( ball, { density = 1.0, friction = 0.3, bounce = 0.2, radius = 25 } )
ball.linearDamping = 0.4[/lua]

I hope this will help you.

Regards.
Francisco.
[import]uid: 11749 topic_id: 7246 reply_id: 25477[/import]

Thank you very much for your help, I fixed the problem and the same error came up again. Any other problems people can find.
[import]uid: 41573 topic_id: 7246 reply_id: 25479[/import]

[lua]local function spawnBall( event )
local phase = event.phase
if “ended” == phase then
myLabel.isVisible = false

physics.addBody( ball, { density = 1.0, friction = 0.3, bounce = 0.2, radius = 25 } ) ball.linearDamping = 0.4
ball.angularDamping = 0.6

ball:addEventListener( “touch”, dragBody ) – make object draggable
end
end[/lua]

the ball table referenced on line 6 doesn’t seem to be created in this function. is ball a global or something? [import]uid: 33520 topic_id: 7246 reply_id: 26050[/import]