![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | 99week |
Like, every second it adds 0.5 to var numb, when the button is no longer pressed, loop breaks and var numb becomes 0?
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | 99week |
Like, every second it adds 0.5 to var numb, when the button is no longer pressed, loop breaks and var numb becomes 0?
![]() |
Reply From: | alexandremassaro |
Add a button and a timer to your scene, connect the button_down and button_up signals of the button and the timeout signal of the timer, then use the following code:
var numb = 0.0
onready var timer = get_node("Timer")
func _on_Timer_timeout():
numb += 0.5
func _on_Button_button_down():
timer.start()
func _on_Button_button_up():
numb = 0.0
timer.stop()