+2 votes

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 :/

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 :P

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?

in Engine by (64 points)

1 Answer

+2 votes

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.

by (1,032 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.