how to block the mouse_enter when the node is overlapping?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ZX-WT
:warning: Old Version Published before Godot 3 was released.

I want to block a node with area2d that detects mouse _ enter with another node, if the node with area2d is overlapped by another node, it doesn’t detect the mouse _ enter.

:bust_in_silhouette: Reply From: mateusak
func mouse_enter():
   if get_pos().distance_to(other_node.get_pos()) < 1:
      return

   #do code

That’s the code if you want to disable it when it’s entirely overlapped. If you want to stop it even if its overlapping just a little bit, then use:

var Blocked = false
onready var Area2D = get_node("Area2D")

func _process():
   if Area2D.is_monitoring_enabled():
      if Area2D.overlaps_body(other_node):
         Blocked = true
      else:
         Blocked = false

func mouse_enter():
   if Blocked:
      return

   #do code

Or if you want to disable it if any body overlaps it:

var Blocked = false
onready var Area2D = get_node("Area2D")

func _process():
   if Area2D.is_monitoring_enabled():
      if Area2D.get_overlapping_bodies().size() > 0:
         Blocked = true
      else:
         Blocked = false

func mouse_enter():
   if Blocked:
      return

   #do code