0 votes

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 ?

in Engine by (141 points)

1 Answer

0 votes

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)
by (128 points)

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.

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.