popup menu won't show

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

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_action_pressed(“Esc”):
var popup_pause = get_node(“esc_menu”)

i put this in the scene script

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

Xtremezero | 2020-02-21 11:50

:bust_in_silhouette: Reply From: Sween123

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()

i tried using that but it wouldn’t work either

ROBOTOO007 | 2020-02-21 15:22

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.

Sween123 | 2020-02-21 15:34

I added this to my code:

func _process(delta: float) → void:
if Input.is_action_pressed(“Esc”):
var popup_pause = get_node(“esc_menu”)

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

ROBOTOO007 | 2020-02-21 15:37

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.

Sween123 | 2020-02-21 15:43

:bust_in_silhouette: Reply From: ROBOTOO007

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_action_pressed(“Esc”):
var popup_pause = get_node(“esc_menu”)
popup_pause.rect_position = Vector2(-76,-63)

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