Legacy GM Help preventing events in overlapping objects

Let's say I have two objects, both with a mouse enter event. If one object is over the other one and I move my mouse over one, the one underneath will fire as well. What is the best way to prevent this? Depth/mask doesn't seem to affect it. Right now I use a hack-y "is this object visible and are the width/height is over the other object" method, and in the past tried "collision detection, check depth, disable the further away one" but both solutions disable the whole object but the event should still work on partially exposed areas of the object underneath. It also adds a ton of code to every object I need to check like that. I feel like I'm missing something simple. Any ideas? Thanks!
 

jazzzar

Member
the depth thing should work, make it that it picks the one with the lowest depth (which appears over the top) the code should look like this :
Code:
if mouse_check_button(mb_left)
{
      if point_distance(obj1.x,obj1.y,obj2.x,obj2.y) <=0
      {
                obj1.x=mouse_x;//assuming obj1 has the //lowest depth
                obj.y=mouse_y
       }
else
{
      //you know what to put here
}
}
 
Top