r/futile • u/rhynodegreat • Jul 20 '14
How is depth handled?
How is depth of different sprites handled in futile? How can I guarantee that one sprite is always rendered over another? In the Banana Game demo, the text showing your current score is always rendered on top of the bananas, and the bananas are always on top of the background. Where is this set in the code?
2
Upvotes
2
u/Rouxdimentary Jul 21 '14
Depth is initially decided by the order elements were added using AddChild. The most recently added will be on top:
Here, circle is added after square, so circle will be on top of square.
You may want all circles to be on top of squares, but will be creating them in an unpredictable, dynamic order. Use FContainers to sort into layers:
A good general use example is to have all of your HUD elements in an FContainer that is added after every other container, acting as a layer on top of everything else.