Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | sucky |
#if the Button is pressed the first time then it wont count = 0 but the second time it will count +=1, how do I put this in code?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | sucky |
#if the Button is pressed the first time then it wont count = 0 but the second time it will count +=1, how do I put this in code?
Reply From: | Help me please |
You can do it as follow:-
var count = 0
var first_time_pressed = false
func _on_Button_pressed():
if first_time_pressed == false:
first_time_pressed = true
return
count += 1
When the button is pressed for the first time it will make the first_time_pressed
variable true and will break out of the function. When you click the button again it will add 1 to the count
variable