-
You’d be better off using composer.*, but whatever…
-
Never destroy the display group given to you by storyboard (or by composer). It is a managed group and you will kill storyboard/composer.
3. If you need to destroy all the objects placed in that group you can do several things…
A. On create… make a group, add group to group supplied by storyboard/composer, then add objects to that group. Later, delete that group and all children will be destroyed.
B. Iterate as follows to delete all children of any group (your code is incorrect, this is a correction)
-- Modified to clear ONE group i'm not sure what the bs was about, but -- you don't need to clear children groups of a group. Just kill the top group -- local function ClearStage(Grp) if( not Grp ) then return end while( Grp.numChildren \> 0 ) do display.remove(Grp[Grp.numChildren] ) end end
C. Many other better ways… but I’ve given two answers that will work so I think you should be solid.