I have a heterogeneous FlxGroup contains: 10 FlxSprite and 4 FlxText. I add all objects with add(obj) function and their z-indexes determined by add function.
I want to change z-index values of objects in my FlxGroup dynamically while program is running (ex: With mouse click).
I tried things like:
With FlxGroups, the "z-index" is nothing but the array position of the object within the FlxGroup's "members" array. So if you have some FlxGroup "mygroup" it would be simply a matter of changing where your object is in the array "mygroup.members".
EDIT: And to be perfectly clear, it draws in order from the first element to the last, so array position 0 is the "bottom" of the stack.
EDIT 2: Also, just an FYI: FlxState's use the exact same method with their "members" array / add()/remove() logic as well. They're basically glorified FlxGroups themselves.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With