0 votes

Hello!

I'm looking for a way to close a PopUp using a button.
(the PopUp is used to close the game)
Has anyone got an idea how i can do that?

thanks!

Godot version 3.4.4
in Engine by (12 points)

2 Answers

0 votes

Your question is too generic. What do you mean by a button? a control node button? in that case use signals. an input keyboard button? then use an _input() function.

How to trigger it is not the issue? maybe you dont know how to "hide it"? in that case if its a control node, a simple .visible = false could do?

Please try to be more specific to see if I (or someone else) can help you

by (418 points)

I used a node button to activate the pop-up using popup()

You click the "Quit game" button.
It opens a pop-up with two node buttons.
The code I currently have is:

extends PopUp



Func On_QuitGame_clicked():
Popup() 

Func on_QuitYes_clicked():
Get_tree().quit()

func on_QuitNo_clicked():
Pass #I got no idea what to use to close the pop-up again 

Can I do something else to explain my problem? :)

Then a simple self.visible = false should do the trick!

edit: the same can be done with self.hide(), and you dont even need the self reference I think, but havent used godot for a time now, so dont quite remember

0 votes

In the Asset Library Projects download either of 2D Platformer Demo.
You'll the example of what you want and there is script too.

by (196 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.