I have a progress bar within canvas layer. I want to change the color...as the time goes low. How can i do this? thanks

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By yeeshu06
:warning: Old Version Published before Godot 3 was released.

Help needed. Cant use tween, doesnt work. thanks. Help needed asap. Thanks

Can you show me your code ?

Skyfrit | 2017-08-21 15:09

This is the tween variable declared in beginning, and Tween as in Node is added under Progressbar Node :

onready var tween = get_node("Tween")

This is the code for changing color that i found on questions.

 if time > 0 && time <= 25:
 #Attempt to change color of progress bar as time goes below 25 seconds
     tween.interpolate_method(get_node("Control/ProgressBar").get("custom_styles/fg"), "set_bg_color", Color("0081ff"), 
		#Color("ffffff"), 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
		#tween.start()

This is the code that i put in the time constraint, in so the color changes as time in progress bar goes under 25. Thanks.

yeeshu06 | 2017-08-21 15:18

Did the tween node connect to tween_step signal ?

Skyfrit | 2017-08-21 15:27

I dont think it does. When time strikes 25, this error pops up.

Attempt to call function 'interpolate_method' in base 'null instance' on a null instance

yeeshu06 | 2017-08-21 15:30

That means it can’t find the Tween node.

You need to give the correct NodePath.

onready var tween = get_node(“Tween”)

Skyfrit | 2017-08-21 15:44

:bust_in_silhouette: Reply From: VitaZheltyakov

https://forum.godotengine.org/16155/want-to-the-change-the-color-of-progress-bar-progress-any-idea

I tried that. It didn work. I dont know what i am doing wrong.

yeeshu06 | 2017-08-21 12:48