Hi friends,
what would be the most effective way to duplicate a Sprite that contains other sprites, sounds, bitmaps?
I would like to give my class a Sprite container and duplicate it so that I can, after that, reScale/change Alpha/setPosition the new layer.
The new layer would be a complete copy of the one given as a parameter (sprites, sounds, bitmaps, animations).
It's important to know that the depth of the hierarchy (Sprite container, subcontainer, etc..) is unknown at first.
How would you do?
Comments
http://www.giderosmobile.com/forum/discussion/1000/best-way-to-perform-a-deep-copy-of-an-object
As for how to implement it, I guess that depends on the structure. If it's unknown, you might need some kind of recursive table copy function as discussed here...
http://lua-users.org/wiki/CopyTable
(I'm surprised if there isn't an easier way.)
Thank you I will try and I hope I can achieve it thanks to those links.
I am surprised that this is a need only a few people have.
Cloning a sprite container can be very useful.
If anybody wants to add his own links and methods, i'm all ears.