What I’m trying to do is remove balloon when I change scene heres what I mean.
-- This function is repeated 7 times with variable not changed
local group = display.newGroup()
local spawnBalloon = function()
if spawn == true then
ball = display.newImage( group, "balloon.png" )
ball.x = 60 + math.random( 160 )
ball.y = 550
physics.addBody( ball, { density=0.0, friction=0.1, bounce=0.1 } )
ball:addEventListener( "touch", spawnBall )
balls[#balls + 1] = ball
ball.name = "ball"
end
end
timer.performWithDelay(500, ball, -1)
local function delete()
for i=group.numChildren,1,-1 do
local child = group[i]
if group[i].y \< -100 then
display.remove(group[i]) -- dont know about this part, try it
end
end
end
Runtime:addEventListener("enterFrame", delete)
-- This function is the quit which is suppose to change scene
local function quit (event)
if event.phase == "ended" then
director:changeScene ("play")
bkg:removeSelf()
Quit.isVisible = false
Resume.isVisible = false
Pause.isVisible = false
end
end
Quit:addEventListener ("touch", quit)
What I’m trying to do is remove the balloons when I change the scene to next scene. Every time I change I see balloons in the next scene. Also when I put localGroup:insert(ball) I would get an error. So can any body help me figure out this problem. [import]uid: 17058 topic_id: 19334 reply_id: 319334[/import]
[import]uid: 17058 topic_id: 19334 reply_id: 74599[/import]