options = {} options.text = "Hello World" options.x = 150 options.y = 150 local g = display.newGroup() local myText1 = display.newText( options ) g:insert(myText1) local myText2 = display.newText( options ) g:insert(myText) local myText3 = display.newText( options ) g:insert(myText3) local myText4 = display.newText( options ) g:insert(myText4) local myText5 = display.newText( options ) g:insert(myText5) . . . local myText10000 = display.newText( options ) g:insert(myText100) for i=g.numChildren,1,-1 do local child = g[i] child.parent:remove( child ) child = nil end if myText10000 then print("I am still here.") // will be printed end
In this way, every textObject will be disappear on the screen.
But “I am still here.” will be printed. That means every textObject is still exist.
So is this the appropriate way to remove every child from a group? And if this is not the right way, what should I do.
Thank you for the time.