Popup close animation

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

Hi! Here I found how to open popup with animation. But how to do same on closeing? I tried this:

func popup_hide():
    var tween : Tween = get_node("Tween")
    tween.interpolate_property(self, "modulate:a", self.modulate.a, 0.0, 0.3, Tween.TRANS_LINEAR, Tween.EASE_IN)
   tween.start()

But it doesn’t work for me. It looks like I should to run animation and use popup.hide() only after it. But how to use it for non-exlusive popups? Or are there other way?

Thanks

What is your working code to open it?

(Sorry putting this as an answer. Fat fingers.)

rtideas | 2021-06-20 20:43

Why you put it into answer, not comment?

Okay.

func _ready():
    connect("about_to_show", self, "_on_about_to_show")
    ...

func _on_about_to_show():
    var tw = Tween.new()
    add_child(tw)
    tw.interpolate_property(self, "modulate:a", 0.0, 0.99, 0.2, Tween.TRANS_LINEAR, Tween.EASE_IN)
    tw.start()

TimiT | 2021-06-21 17:15

:bust_in_silhouette: Reply From: exuin

Popups aren’t really meant to have a closing animation. I think it would be easier for you to just use a normal panel or something like that to animate it closing.