Hey! I'm making a game (tower defense) and when when I drag a tower over an area and drop it there, it's suppose to spawn a new object on the area(which is a sprite), but the problem is that if it's over two of the same areas, I don't know which one it's gonna land on. Can someone help me?
The best and easiest way to solve this is to use a pick nearest/furthest action, when you drop the tower on the sprite where you want to spawn it. I guess you have some conditions that when you drop the Tower you want to place, you also check whether its overlapping this sprite where you can place it.
Now if the Tower overlaps several sprites your pick counter of those sprites is likely to be greater than 1, but since you are also for certain closer to the sprite where you actually want to place the tower than those where you don't want to. You can use the pick nearest/furthest action to pick the sprite closest to the Mouse.X, Mouse.Y.