0 votes

i would like to create a countdown timer that uses the progress bar as timer?

asked Dec 30, 2019 in Projects by Regret (29 points)

1 Answer

+1 vote
Best answer

Create a new scene. Add two nodes, a ProgressBar and a Timer. Create a new script for the root node of the scene. Write the following code in it:

extends Node2D
onready var timer = get_node("Timer")
onready var pb = get_node("ProgressBar")

func _ready():
    timer.wait_time = pb.value

func _process(delta):
    #print(timer.time_left)
    pb.value = timer.time_left

Now your Timer uses the ProgressBar's value as its countdown time. You can even see the ProgressBar decreasing as time goes by.

In case you didn't know, you can set the ProgressBar's value by using its value method.
If this is what you want, please mark this answer as best.

answered Dec 30, 2019 by johnygames (1,839 points)
selected Dec 30, 2019 by Regret
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.