0
votes

I'm making a game in Corona SDK which is like you get a balloon spawned and it will be falling down, and when you press that balloon it disappears and it should spawn another one and so on, I've managed to set up the first one so when you tap on it it gets destroyed, and I got a function that gets called when you tap on the balloon, here it is:

function onBalloonTap (event) 
    balloon:removeSelf()
    audio.play(blingsound)
    local balloon = display.newImageRect( "balloon.png", 128, 200 )
    balloon.x, balloon.y = 160, -100
    balloon.rotation = 10
    physics.addBody(balloon, { density=1.0, friction=0.3, bounce=0.5 })
end

It works perfectly, and it spawns another balloon as you can see, but I can't tap on it or anything, I don't know how can I spawn another balloon so that everything that applies to the first applies to it.

1
I'd expect something like that to be covered in any tutorial for your framework. The code you present is insufficient. It is unclear to what events (under which conditions) the program runs this function. If you find out how did you create the first baloon, you'll be able to do the same for the second one. - Dimitry

1 Answers

0
votes

You need to add new event listener to the new ballon.