I’m wondering how do I remove items on certain height when they fall
I’m trying to do it on this game where balloons fall above and are remove on touched. But I also want them to be removed by itself when they fall on certain height.
Here the code for the balloon I’m saying
–Destroying balloons and adding +1 score
local spawnBall = function( event )
local t = event.target
local phase = event.phase
if “began” == phase then
t:removeSelf() – destroy object
score = score + 1
scoreText.text = score
end
– Stop further propagation of touch event
return true
end
ball:addEventListener( “touch”, spawnBall )
–Balloon is created and at what height and to fall
local balls = {}
local spawnBalloon = function()
ball = display.newImage( “balloon.png” )
ball.x = 60 + math.random( 160 )
ball.y = -100
physics.addBody( ball, { density=0.0, friction=0.1, bounce=0.1 } )
balls[#balls + 1] = ball
end
timer.performWithDelay(500, spawnBalloon, -1)
When I’m trying to get across is how would I remove a falling balloon at a certain
help please
[import]uid: 17058 topic_id: 19250 reply_id: 319250[/import]