+1 vote

I am showing a sprite and would like to have a coded way to make a sprite disappear after showing for five second without using animations.

in Engine by (59 points)

3 Answers

+1 vote
Best answer

Have you looked into using a Timer? Set the Timer to "One shot", then assign its timeout() signal to some script (such as the sprite's script). Set the signal function (the one that's usually called _on_timer_timeout()) to either hide the sprite, or free it completely. The function would look like this:

# In the sprite script.
func _on_timer_timeout():
    # Either call this function or hide()
    queue_free()
by (2,232 points)
selected by
0 votes

You can show the sprite start a timer then use the timer's timeout signal

func on_timer_timeout():
    $Sprite.visible = false
by (32 points)
0 votes

I'm new to Godot but I think you can use the timer node and use signal to connect it to the sprite. Then on the inspector increase wait to 5.
That's it I think

by (14 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 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 webmaster@godotengine.org with your username.