Topic was automatically imported from the old Question2Answer platform.
Asked By
DrPlamsa
Hello:
How can I set a Node2D or a Control to show behind the root viewport? I have some items that I only want to display if there’s nothing shown in the root viewport at that location. I already know to do get_viewport().transparent_bg=true, but for the life of me I can’t figure out how to use Node2D’s z-indices or Control’s show behind or show on top features to get them to display behind the root viewport.
Viewport children will draw by default at layer “0”, while a CanvasLayer will draw at any numeric layer. Layers with a greater number will be drawn above those with a smaller number. CanvasLayers also have their own transform and do not depend on the transform of other layers. This allows the UI to be fixed in screen-space while our view on the game world changes.
An example of this is creating a parallax background. This can be done with a CanvasLayer at layer “-1”. The screen with the points, life counter and pause button can also be created at layer “1”.