Using Godot 3.1, I have func _unhandled_input(event):
I want to use this function in so many sprites
So sprite1, it has to be attached as a script to it and so one, for each sprite I need to use that function on, it needs to be attached to the sprite
func _unhandled_input(event):
if play == True:
if (event is InputEventMouseButton and event.pressed and not event.is_echo() and event.button_index == BUTTON_LEFT) or (event is InputEventScreenTouch):
if get_rect().has_point(to_local(event.position)):
#code here
get_tree().set_input_as_handled()
I want to pass a variable to it on every different sprite, the problems that I have
- I cannot pass variables to it, it only accepts event as an argument
- I cannot put it in another function
- I cannot as far as I know extend it
- I cannot store it in a global script file, it needs to be attached to a parent node
- I don't want to copy paste