How can I reverse a pause in a different function?

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

Hi. I was just wondering on how to reverse a pause in a different function. U can see that in the code below, in one function, I have the pause code as true and on the second function, I have the pause code set to false. In context of my code, I am making a pacman game and in the first function, I said that when the enemy enters pacman, then pause the game and display gameover and the restart button. Then I linked the pressed() node on the restart button to the enemy code and wrote that when pressed, stop pausing the game, restart the game, and hide the gameover and restart button. The restart button works fine when there is no pause but without the pause, the game keeps going on even when enemy eats pacman and I dont want that. Please help me solve my problem.

func _on_Enemy_area_entered(area):
if(area.name == "Pacman"):
	get_tree().paused = true
	get_parent().get_node("gameoverBackground").show()
	get_parent().get_node("gameover").show()
	get_parent().get_node("restartButton").show()

func _on_restartButton_pressed():
	get_tree().paused = false
	get_tree().reload_current_scene()
	get_parent().get_node("gameoverBackground").hide()
	get_parent().get_node("gameover").hide()
	get_parent().get_node("restartButton").hide()
:bust_in_silhouette: Reply From: wombatstampede

If your button resides in a popup or another kind of control parent set the nodes “Pause” to “Process”.

Default for every node is “Inherit”. So when the parent is paused then also die child is paused which includes the button.

Think of the parent like a branch you sit on. When you (the button) saw the branch you’ll normally inherit the behaviour of the branch. If it falls down, you will fall down.

But when you remove the “Inherit” Pause mode then you’ll have an anti-gravity suit and just stay in the air. (Until the battery of the suit depletes.)

Im pretty sure what u said makes sense but I am not understanding bcuz im a complete beginner. Thnx for ur help. If u can maybe help me understand it better, I would really appreciate it.

Edaad | 2019-04-06 01:34

Never mind, I managed to figure it out. Thanks so much!

Edaad | 2019-04-06 01:51