0 votes

Hello!
I have a scene created in Godot 2D, in which I have created also a CanvasLayer ( that contains a Control with a Container and buttons) . This Control script is not visible during the game.

After I finish beating the enemy I want to make visible my CanvasLayer/Control , while the main game is put on pause.

So, I beat the enemy:
I have a global variable that is put on true, then I acces funconWorld10_acces(). And this is the code of my control. The game is paused, ( which is what I wanted) , but when I click on my buttons nothing happens.

extends Control

func ready():
$MarginContainer/CenterContainer/VBoxContainer/Start.grab
focus()

func physicsprocess(delta):
if $MarginContainer/CenterContainer/VBoxContainer/Start.ishovered()== true:
$MarginContainer/CenterContainer/VBoxContainer/Start.grab
focus()
if $MarginContainer/CenterContainer/VBoxContainer/Quit.ishovered()== true:
$MarginContainer/CenterContainer/VBoxContainer/Quit.grab
focus()

func onWorld10acces():
get
tree().paused= not get_tree().paused
visible = not visible

func onStartpressed():
get
tree().paused= not gettree().paused
get
tree().change_scene("res://StartMenu.tscn")

func onQuitpressed():
get
tree().quit()

Do you know how I can resolve this?

asked Jun 8 in Engine by Riri (22 points)

2 Answers

+2 votes
Best answer

By default, nodes will not be able to respond when the game is in a paused state. You can selectively change that as necessary. Just change the Pause property (in the inspector for the node(s) in question). The value defaults to Inherit, which causes them to react just like their parent. Setting the value to Process will allow the node to continue to process events even while the game is paused...

answered Jun 8 by jgodfrey (5,706 points)
selected Jun 9 by Riri
0 votes

Could you put your code under code tags so it is readable? Impossible to read well like this.

answered Jun 8 by jtarallo (376 points)

While I agree with your statement, this should be posted as a Comment rather than an Answer (which, it obviously is not)... ;^)

You're right, my bad. Sorry, but just started here yesterday. Kinda obvious what you point out, but I didn't realize, so thanks. Will keep it in mind for the future :)

Understood - we're all new at some point. Thanks for your understanding and welcome!

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 How to use this Q&A? before posting your first questions.