FlxGroup add to end of members #2614
Replies: 3 comments 8 replies
-
I think the best available workaround at this point is to manually splice |
Beta Was this translation helpful? Give feedback.
-
Agreed, I think you should splice members when removing to ensure that there are no null indices in the group. this is what I do. There are also a lot of techniques to use when z-order is important, like using FlxSort on groups, or having foreground, midground, and background groups to ensure different objects always appear on top or bottom of each other. Gonna convert this to a discussion, since it's not a technical issue, more of a tip or methodology |
Beta Was this translation helpful? Give feedback.
-
I would rather be able to provide a function |
Beta Was this translation helpful? Give feedback.
-
Currently,
FlxGroup.add()
has no option to guarantee that the new object will be added at the end of its member array. If I want toremove()
andadd()
an object to bring it visually to the front of the game, I can only do that if I remember to callremove()
with thesplice
argument true every time. Additionally, if I use any library/plugin that callsremove()
without splice, I open myself up to Z-sorting errors.I could manually
push()
the element tomembers
, but this won't update the FlxGroup's length.I suggest that
add()
could take an optional "at end" argument, which guarantees that the given object ispush()
ed onto members, not put at the first null index.Beta Was this translation helpful? Give feedback.
All reactions