Is it possible to automatically align an AnimatedSprite2D inside any kind of control?

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

I have created a button scene and wish to add an animated sprite as an icon.

It seems that the animated sprite can only be positioned either manually, or via code. Is there no way to make it adhere to its control container like other control elements?

:bust_in_silhouette: Reply From: danielmeridew

Never mind I just realised you can use a TextureRect to do this.

Hi @danielmeridew, if you don’t mind my asking – how did you achieve this with the TextureRect?

I was only able to achieve alignment with an “AnimatedTexture” inside it, but according to the documentation that feature will be soon deprecated. I then tried to add an AnimatedSprite2D as a child to the TextureRect, and it does seem to link to its centre, but otherwise does no obey any other settings for size/allignment/etc., forcing me to set scaling and offsets manually each time, which is quite cumbersome :-/

mgc8 | 2023-06-20 23:59