(re)moving a display object from one group to another...

This has probably been covered, but its getting late and I'm not ever sure what to search on.

I have a display object, lets call it "fred".

It is inside of a display.newGroup called rockquarry.

I have another display.newGroup called bedrock.

I want to move fred from one to the other. However calling rockquarry:remove(fred) actually deletes the display object. I don't want to delete it, or even delete it and re-create it.

Thoughts?

Note

That if you insert a display object into one group and then later insert the same object into another group, the display object is removed the original group into which it was inserted. An object can only exist in one group at a time. The following code sample illustrates this:

taken from

http://developer.anscamobile.com/content/display-objects#Groups

Jeff has it right,

so

1
2
3
4
5
6
7
 local groupA = display.newGroup()
 local objA = display.newRect(groupA,10,10,100,100)
 
 local groupB = display.newGroup()
 local objB = display.newRect(groupB,10,10,100,100)
 
 groupB:insert(objA)
views:1610 update:2011/10/25 9:10:48
corona forums © 2003-2011