Control.open()?

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

If you open up the 2d Platformer template project (a great help for getting started on a game, btw), it’s got a lot of great examples of game components, including some UI elements.
I had a question regarding one of the components, though. In the main Game node, as a child of the InterfaceLayer (a CanvasLayer node), there is a Control node called PauseMenu. In the Game.gd script, there is a portion that listens for a pause command (the escape key press), and at that point, there is a line that says:

_pause_menu.open()

I cannot find anywhere that documents this Open function. According to the docs, Control doesn’t have this as a member. As I’ve been trying to translate the scripts in the 2dplatformer template to C# (for my own enjoyment), I’m unable to find a corresponding function.

does anyone know where this function comes from, or what Node it’s meant to go with? I’m assuming there may be some dynamic typing going on for this that I’m missing.

:bust_in_silhouette: Reply From: jgodfrey

I just took a look at the source. The PauseMenu node is just a Control (as you correctly noted). If you look at the script attached to the node itself (PauseMenu.gd - where the _pause_menu.open() code lives), you’ll see that open is just a local script function containing this code:

func open():
	visible = true
	resume_button.grab_focus()

So, it just sets the control’s visibility state and focus…

oh, yes. Thank you for that!

2ndGarrison | 2020-04-29 03:51