Using animated sprite as a GUI control?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SasQ
:warning: Old Version Published before Godot 3 was released.

Is there any way in Godot to use an animated sprite as a GUI control?
E.g. playing some frame-by-frame sprite animation when a button is being hovered by the mouse pointer.

I checked out Button and TextureButton, but they don’t seem to have any means for animating the textures. They can only use static images for the different states of the button :confused:

On the other hand, Godot’s developers in their infinite intelligence didn’t derive Sprite and AnimatedSprite from Control ;` so they lack the typical functionality of a GUI control, like handling user input or layout :stuck_out_tongue:

Is there any way around this?
Maybe making a custom control extending one of the control classes that would use a Sprite or AnimatedSprite for displaying itself?

:bust_in_silhouette: Reply From: rolfpancake

Just two thoughts:

Use an Area2D to get the input events

Sprite/AnimatedSprite
|> Area2D
   |> CollisionShape2D

And then send the input signal of the Area2D to your sprite-script.

Use Control as a parent node

Control
|> Sprite/AnimatedSprite

But maybe there are better ways.