Attention | Topic was automatically imported from the old Question2Answer platform. | |
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()