Closing pop-up

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

Hey, Im am trying to do a very simple thing: when button is pressed a pop-up window must appear a progress bar should be filled over time and then the pop-up window must be closed.
The pop-up window is called from the main node

_func _on_Survey_Area_pressed():
surveilance.popup()

The code attached to the pop-up window is following:

onready var timer = $Timer
onready var progressBar = $SurveilanceProgressBar

func _ready():
timer.start()

func _on_Timer_timeout():
if progressBar.value < 10:
progressBar.value +=1
else:

	

so the question is what do I write in the else block to close the window and reset everything, so i would be able to open the pop-up window again and timer/bar would start from 0

Or is it better to do this from the parent node?

Thank you

P.S. For some reason code formatting is all screwed up here, sorry for that

:bust_in_silhouette: Reply From: supper_raptor

Try surveilance.hide()

Didn’t work for some reason, at least when I tried to do in within a script attached to the pop-up Node, I solved it with queue_free() , which however introduced another issue, that I had to create a pop-up node anew. And since I only knew how to instantiate new scenes, I moved the whole thing to another scene and call it every time the button is clicked with

var surveilance = preload("res://Surveilance.tscn").instance()
add_child(surveilance)

which is probably the better approach in general.

OlegM | 2020-05-29 17:21