Clone Scene2D stack

Anything libgdx related goes here!

Clone Scene2D stack

Postby yobowargames » Tue Aug 13, 2019 3:39 am

Is there a way to clone the Scene2D stack? It says in the wiki that it inherits class java.lang.Object including clone. But clone method if not available. I want to clone and not copy.

Posts: 15
Joined: Sat Oct 27, 2018 4:25 pm

Re: Clone Scene2D stack

Postby shatterblast » Tue Aug 13, 2019 6:35 am

While I have not tried, I do not think that Object#clone() will work on Actor or things inheriting from it. It might relate to the event system tied to Scene2D. I believe that a cloned Actor or similar does not automatically register itself with the necessary events coming down Scene2D's chain, so even with a listener, the cloned object ends up not firing off on any. If I understand, I think a feature may possibly come in the future to address it, but now, I have nothing to offer you.
Posts: 653
Joined: Sun Jul 06, 2014 1:14 pm

Re: Clone Scene2D stack

Postby Magnesus » Wed Aug 14, 2019 7:11 am

You might have to iterate the whole scene and clone it manually actor after actor, action after action. It is probably easier than it sounds with some recursion for groups and sequence actions.
Posts: 1709
Joined: Sun Sep 25, 2011 3:50 pm

Return to Libgdx

Who is online

Users browsing this forum: No registered users and 1 guest