Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | MDordio | |
Old Version | Published before Godot 3 was released. |
I am making a quiz game and i want to show a sprite(“this_image”) that contains an image when the correct answer is pressed and then changes question.
what i am doing is this:
func _on_lbl_answer1_pressed():
if(oi3 == correct_answer):
correct_answer()
this_image.show()
Globals.get("array_pergunta").append(i+1)
elif(oi3 != correct_answer):
wrong_answer()
i+=1
generate_table()
func generate_table():
if(i>=dict.size()):
get_tree().change_scene('res://Scenes/Scoreboard_M.tscn')
else:
this_image.hide()
var k = dict[keys2[i]]
correct_answer = k["res_c"]
lbl_question.set_text(k["question"])
randomize()
for i in range(keys.size()):
var random_index = randi() % keys.size()
var k1 = keys[i]
var k2 = keys[random_index]
keys[i] = k2
keys[random_index] = k1
lbl_answer1.set_text(k[keys[0]])
lbl_answer2.set_text(k[keys[1]])
lbl_answer3.set_text(k[keys[2]])
lbl_answer4.set_text(k[keys[3]])
oi = lbl_answer1.get_text()
oi1 = lbl_answer2.get_text()
oi2 = lbl_answer3.get_text()
oi3 = lbl_answer4.get_text()
The code above in fact shows the image when i press the correct button and then changes the question but the problem is the image stays visible and i would like to “turn it off” as soon as the question change.
Is there away to do this?
PS: if needed i will provide the rest of the code
You are showing the image in func _on_lbl_answer1_pressed()
and calling generate_table()
where it immediately gets hidden again. You will need a timer if you want to show it for a given amount of time before hiding it again. Alternately, you can wait for the user’s input for the next answer and hide it then.
I hope I’m understanding your intentions properly.
Michael Paul | 2017-12-15 01:08