Hi!
I want to create new obiect but output throw me
attempt to call method 'applyForce' (a nil value)
my function to create ‘ball’
function startBall() local ball = display.newRect(\_W + math.random( -400,400),\_H + math.random( -300,300) ,30, 40); physics.addBody(ball, "dynamic"); ball.myName = "ball"; ball:applyForce(math.random( -20,20), math.random( -20, 20), ball.x, ball.y ); end
And my onColision where i invoke my function
function onCollision( event ) if ( event.phase =="began" ) then local pacman = event.object1; local ball = event.object2; if(ball.myName == "ball") then ball:removeSelf(); startBall() end end end
When i invoke my method outside onCollision everythink work fine.
Thanks in advice!