Is it better to use a Sprite or a TextureRect for a background?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaaaxiKing

I don’t see the differences except that Sprite is a child of Node2D and TextureRect is of Control. The background should be a ParallaxBackground.

:bust_in_silhouette: Reply From: meadcg

It is stated in the official docs that

TextureRect => “Used to draw icons and sprites in a user interface.”
Sprite => “A node that displays a 2D texture.”

So I believe it’s better to use TextureRect for the user interfaces and Sprite for the background.
The reason probably has something to do with, Sprite being more optimized for in game world use than TextureRect, although they can both deliver the same functionality as background so nothing is stopping you from using them both as such.

Hope this helps

Sprite being more optimized for in game world use than TextureRect

I would say TextureRect has a number functionalities of Control, which are redundant for this case.

sash-rc | 2022-02-02 19:20

:bust_in_silhouette: Reply From: avnih

TextureRect is a Control. Controls have placement rules (e.g. anchor, margin), they can react to user input, and they can take focus.