- Edited
I'm trying to make the clock (label) change color to random when clicked.
extends Label
# Called when the node enters the scene tree for the first time.
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var time = Time.get_time_dict_from_system()
$".".text = str(time.hour) + ":" + str(time.minute) + ":" + str(time.second)
func _input(event):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
$".".add_theme_color_override("font_color", Color((randi() % 255), (randi() % 255), (randi() % 255)))
print($".".get_theme_color("font_color"))
judging by what print() outputs, everything works, and I get 3 random numbers in the range from 0 to 255, but the color does not change.
at the same time, if I enter any 3 numbers myself instead of randi(), the text color will successfully change after clicking.
$".".add_theme_color_override("font_color", Color((randi() % 255), (randi() % 255), (randi() % 255)))
-> $".".add_theme_color_override("font_color", Color((100, 41, 96))
what is the problem?