How to make a animation start when a button on screen is pressed ??

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

My nodes are like this
Control
Colour rect (Background)
Button (change scene to the game )
colour rect (to create the fading effect)
animation player (Black to Transparent animation of colour rect)

I want to create a fading effect between the menu screen and the game.
I want to make it like the animation starts when the button on the screen is pressed so it looks like a fading effect.
Please me with this code or is there a better way to do it.
(Explain Briefly and NO LINKS ALLOWED )

Hi!

I would attach a script to the colour rect, initiate the _on_Button_pressed() signal from the Button, connect it to the colour rect script and start it’s animation with animationplayer from the connected function in the script with code.

Something like this (only illustration):

func _on_Button_pressed():
    $AnimationPlayer.play(...)

indruckbalazs | 2020-10-02 15:57

Explain Briefly and NO LINKS ALLOWED

Hmmm… That seems like a strangely limiting request. Why would you not accept help in any form that someone chooses to provide it?

jgodfrey | 2020-10-02 15:45

@jgodfrey Because people come and give links and say that go here and you will know everything and it is always the Godot doc Website which I know already.
If I know that link already then why did I came here to ask for help, there should be a reason for that that someone would explain that briefly to me.

Siddharth Pushkar | 2020-10-02 15:56