Hello all, I have my objects created in table balloons. The objects name is balloon. I put table balloons inside of localGroup. Now when the player runs out of darts I want to remove whatever balloon are left on screen before building the next level. The problem I am having is I don’t know how to access the table balloons inside of localGroup to remove the remaining balloon objects on screen. Here is my code…
[lua]function buildLevel(level)
local len = table.maxn(level)
balloons:toFront()
for i = 1, len do
for j = 1, W_LEN do
if(level[i][j] == 1) then
local balloon = display.newImage(“Blue_Base_Shadows.png”)
balloon.name = “balloon”
balloon.x = BALLOON_W * j - OFFSET
balloon.y = BALLOON_H * i
physics.addBody(balloon, {density = .5, friction = 0, bounce = 0, radius= 15})
balloon.bodyType = ‘static’
balloons.insert(balloons, balloon)
end
end
end
spawnScreenDarts()
end
-------then in the initialize function I do this
localGroup:insert(balloons)
----then I call this function
function changeLevel(event)
if dartsLeft == 0 or balloons.numChildren == 0 then
print(dartsLeft)
print(localGroup.numChildren)
localGroup:remove(balloon)
end
end
-----then in the initialize function I call changeLevel at runtime
Runtime:addEventListener(“enterFrame”, changeLevel)
[import]uid: 49863 topic_id: 29523 reply_id: 329523[/import]
