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
- Zero size. A ColorRect under a Node2D has no parent rect to anchor to. Set its
sizeexplicitly, or put it under a Control with the Full Rect preset. - Transparent colour. Check the alpha of
color, plusmodulateandself_modulate. - Different canvas layer. A ColorRect inside a CanvasLayer with layer 1 is always above the world; one in a ParallaxBackground (layer -100) is always behind it. Layers win over z_index.
- Off-camera. A ColorRect at (0, 0) in world space stays there while the camera moves. For a background that always fills the screen, put it in a CanvasLayer with a negative layer, or use Project Settings > Rendering > Environment > Default Clear Color if a flat colour is all you need.