Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Sprite
- var mouseOn = false
- func _input(event):
- if event is InputEventMouseButton:
- if event.is_pressed() == true and event.get_button_index() == 1:
- #if is_pixel_opaque(to_local(event.position)):
- if get_rect().has_point(to_local(event.position)):
- mouseOn = true
- print("Click ", get_name())
- get_tree().set_input_as_handled()
- elif event.is_pressed() == false:
- if mouseOn == true:
- mouseOn = false
- print("Clicked ", get_name())
- elif event is InputEventMouseMotion:
- if mouseOn == true:
- #if not is_pixel_opaque(to_local(event.position)):
- if not get_rect().has_point(to_local(event.position)):
- mouseOn = false
- print("Out ", get_name())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement