Colour changing when choosing answers in a quiz game.

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

I am creating a quiz game. The answers are button which are in random colours . When a answer is choosen the selected button should change it’s colour to white. If the answer is correct the white colour remains but if the answer is wrong the button should return to it’s original colour. Can anyone tell me how to do it ?

:bust_in_silhouette: Reply From: blank

Easiest thing to do would be to make a white button and modulate it’s color. Call this from custom functions that correspond to the events you described and you are all set.

onready var button = get_node("...")

func _on_answer_selected():
  button.modulate = Color(1,1,1,1)
func _on_answer_correct():
  button.modulate = Color(1,1,1,1)
func _on_answer_incorrect():
  button.modulate = Color(1,0,0,1)

Thanks for your answer. But here the buttons are in random colours and I want the white colour to change to the original colour if the selected answer is wrong.

THE HELIX | 2019-11-25 18:27