You are given a complex Scene2D
graph in libgdx
with several Group's
and Actor's
. You want the user to select some Actors
and draw those at the end so they appear focussed on top of any other Actors
.
I would like to iterate over the Stage
twice. The first time it draws the unselected Actors
, the second time it draws the selected actors
. I don't see any 'good' way to enforce this behaviour however.
I would prefer options that are clean. I would not like to copy an entire method implementation just for the sake of this small addition.
What doesn't work:
- the
Actor's
toFront
() method only works for it's siblings. - swapping places of
Actor's
in the Stage: this modifies the transformations theActors
have.
Scenario to think about: you have a Root
with a group gA and a group gB. Group
gA contains two images iA1 and iA2. Group
gB contains one image iB. Given that Group
gA is added first to the stage and that image iA1 overlaps with iB; now you want to select iA1 and make it appear over iB. I don't want to only call gA.toFront(); this would put the whole Group
gA to the front, which means also iA2 is put to the front. Putting iA2 in front has the undesired effect of hiding parts of images inside Group
gB