![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Cloudurian |
I’m new at coding, so I was looking for how to do a code for a sprite node (named Godot) with a single button (named One) that toggles if it blinks or not.
Here is the code I have:
var seen = 0
func _on_Timer_timeout():
if seen % 2 != 0:
visible = not visible
if seen % 2 == 0:
pass
func _on_One_pressed():
var godot = get_parent().get_node("Godot")
godot.visible = not false
seen += 1
This works as I wanted but I was wondering if there exists a more efficient way to do it rather than constantly checking if the variable seen is an odd number or not
both the timer and One nodes are connected to the sprite node