(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?
[import]uid: 19626 topic_id: 16805 reply_id: 316805[/import]

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
[import]uid: 7911 topic_id: 16805 reply_id: 62922[/import]

Jeff has it right,

so

 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)  

this will remove objA from groupA and move it into groupB

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16805 reply_id: 62961[/import]