0 votes

i'm new to godot and am making a pong game to get familiar with the engine i tried to make a popup menu but it won't show up
here's my code:

func process(delta: float) -> void:
if Input.is
actionpressed("Esc"):
var popup
pause = getnode("escmenu")
popup_pause.show()

i put this in the scene script

in Engine by (120 points)

If there isn't any errors

Make sure that the pop up is not behind another object, (in the nodes tree , lower objects cover the higher ones)

Also make sure the parent is visible
And the scale isn't 0
And the position isn't somewhere off the screen

2 Answers

+1 vote

Use .popup() to display a PopupMenu. For a popup, we don't use .show()
For example, use popup_pause.popup() instead of popup_pause.show()

by (811 points)

i tried using that but it wouldn't work either

If your menu node is a popup type, then .popup() will display it.
The reason why it doesn't work in your game might be because of some other kinds of logical errors in your code. For example, maybe Input.is_action_pressed("Esc") doesn't return true when you press the key "Esc" (maybe the key "Esc" is not an input key for the input action "Esc"). Just check your code again.

I added this to my code:

func process(delta: float) -> void:
if Input.is
actionpressed("Esc"):
print(Input.is
actionpressed("Esc"))
var popup
pause = getnode("escmenu")
popup_pause.popup()

and it returns true in the console
but still doesn't show anything

Sorry...Because I don't know your game world, I don't know what exactly is wrong. Maybe you get the wrong popup menu, or maybe your menu is somewhere else far away from your screen, there can be many small possible problems that get you the wrong results, but the method .popup() itself for a popup node type is the method that will display it.

0 votes

i found out the problem i needed to manually change the position of the rectangle in the popup_menu using this code :

func process(delta: float) -> void:
if Input.is
actionpressed("Esc"):
var popup
pause = getnode("escmenu")
popuppause.rectposition = Vector2(-76,-63)
popup_pause.popup()

for some reason it won't go past the half of the screen, for example if is set it's position to 0 , 0 it will be the same as -40, -40

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