I’m trying to launch an object with applyLinearForce. The following code crashes and says I attempted to call applyLinearForce (a nil value).
[lua]–Global touch listener for shooting
function shoot(event)
if event.phase == “ended” then
timer.performWithDelay ( 1, shootBall )
end
end
Runtime:addEventListener ( “touch”, shoot )
function shootBall()
local shooterball = shooterball.spawn()
shooterball.x = monkey.x
shooterball.y = monkey.y - 30
physics.addBody ( shooterball, {density=1.0, friction=0.0, bounce=0.8, radius = 20})
shooterball:applyLinearForce(1,1000,shooterball.x,shooterball.y)
end[/lua]
I can’t figure it out and I’m new to Corona, if anyone has quick thoughts that’d be awesome. Thanks [import]uid: 161435 topic_id: 28395 reply_id: 328395[/import]
[import]uid: 52491 topic_id: 28395 reply_id: 114662[/import]