button.gd 416 B

1234567891011121314151617181920
  1. extends Area2D
  2. @export var color : String
  3. var objects_count : int = 0
  4. func _on_cbutton_toggled(button_enabled : bool):
  5. get_tree().call_group("button_listeners", "on_button_toggled", color, button_enabled)
  6. func _on_body_entered(_body):
  7. if objects_count == 0:
  8. _on_cbutton_toggled(true)
  9. objects_count += 1
  10. func _on_body_exited(_body):
  11. objects_count -= 1
  12. if objects_count == 0:
  13. _on_cbutton_toggled(false)