@TheRealTonyK
Here is the code:
[lua]physics = require( “physics” )
physics.start()
physics.setGravity(0 , 9.8)
local cannon = display.newRect( 0, _H-75, 40, 60 )
local function shoot (event)
local ball = display.newCircle( cannon.x, cannon.y, 20 )
ball:addEventListener(“collision”, ball)
physics.addBody( ball, “dynamic”, { density=1, friction=0, bounce=0.2 })
function ball:collision (event)
if event.other.hit == “deleter” then
ball:removeBall()
end
end
function ball:removeBall ()
ball:removeSelf()
end
ball:applyLinearImpulse(( ball.x - event.x) * -0.055, (ball.y - event.y) * -0.08, ball.x, ball.y )
– My idea was to use the following code:
– transition.to( ball, { time=1000, onComplete = ball:removeBall()})
– but it simply doesn’t work
end
Runtime:addEventListener(“tap”, shoot)[/lua] [import]uid: 101952 topic_id: 24347 reply_id: 98486[/import]