How to remove groups within groups?
i have:
function scene:createScene( event )
local screenGroup = self.view
–.
–.
–.
Layer_Categories = display.newGroup();
screenGroup:insert(Layer_Categories);
How remove “Layer_Categories”??
group:remove ( Layer_Categories ) ???
Layer_Categories=nill
or group:remove ( screenGroup:Layer_Categories ) or something…
help me please.
Thanks
[import]uid: 121547 topic_id: 26039 reply_id: 326039[/import]
If the group is local to a function then you can’t remove it from outside that function. But if you localize it outside the function then you can. Example:
[lua]local childGroup, parentGroup
local parentGroup = display.newGroup()
local function doSomething()
childGroup = display.newGroup() --This is still local because of the previous variable
parentGroup:insert(childGroup)
end
display.remove(childGroup) --This will remove the child group from the parent group.
childGroup = nil[/lua]
Hope that helps!
Dac [import]uid: 63320 topic_id: 26039 reply_id: 105402[/import]
how fix it?
function scene:createScene( event )
local screenGroup = self.view
Layer_Fondo = display.newGroup();
screenGroup:insert(Layer_Fondo);
function pintarFondo()
imgFondo = movieclip.newAnim({“imagenes/img_fondo_flags.png”},320,480)
imgFondo.x = display.contentWidth / 2
imgFondo.y = display.contentHeight / 2
imgFondo:stop()
Layer_Fondo:insert(imgFondo)
end
function removeFondo()
display.remove ( Layer_Fondo ) --???
Layer_Fondo = nil --???
end
pintarFondo()
removeFondo() — NOT WORK IT
return scene [import]uid: 121547 topic_id: 26039 reply_id: 105406[/import]
If you are using storyboard you can declare Layer_Fondo before function scene:createScene, if you declare inside that function it only can be handled in that function. This will do the trick:
local Layer_Fondo;
function scene:createScene( event )
local screenGroup = self.view
Layer_Fondo = display.newGroup(); [import]uid: 131209 topic_id: 26039 reply_id: 105447[/import]
Thanks. !!! [import]uid: 121547 topic_id: 26039 reply_id: 105721[/import]