Quick answer: In 2D, nodes later in the scene tree draw on top of earlier ones at the same z_index. Move the ColorRect above the sprite in the tree, or give it a lower z_index (for example -1). If it does not appear at all, check that it has a size and a non-transparent colour, and that it is not on a different CanvasLayer.

ColorRect is a Control and Sprite2D is a Node2D, but they share the same 2D canvas and the same draw-order rules. Once you know those rules, putting a coloured background behind a sprite takes one change.

Rule 1: tree order

Within one canvas layer and one z_index, children are drawn in scene tree order: the node lower in the Scene dock is drawn later, so it appears on top. To put a background behind:

Level (Node2D)
├── Background (ColorRect)   <- drawn first
└── Player (Sprite2D)        <- drawn on top

Rule 2: z_index beats tree order

z_index (under Ordering in the Inspector) overrides tree order. A sprite with z_index 0 is drawn above a ColorRect with z_index -1 wherever they are in the tree:

$Background.z_index = -1

z_as_relative is on by default, so a child's z_index adds to its parent's. A ColorRect under a node with z_index 5 effectively has z_index 5 plus its own.

Rule 3: parents and show_behind_parent

A child draws after its parent. To draw a child behind its parent sprite, enable Show Behind Parent on the child, or use a negative z_index.

Rule 4: y-sort

If the parent has Y Sort Enabled, its children are ordered by Y position instead of tree order. A full-screen ColorRect whose origin is at the top of the screen will then sort behind everything below it — or in front, depending on its position. Keep backgrounds outside y-sorted parents.

The ColorRect does not appear at all

Related fixes