Selecting objects in a 2d game
I'm having a bit of trouble with my gui and the other elements in my 2D game. Currently I'm able to select every object using my mouse. Whenever I hover over something, a lifebar appears, and where applicable, I can perform actions.
The problem is not that difficult, and I already have sort of a solution but I was interested if other solutions might come up.
Here's the thing: how I do prevent sprites or gui elements to perform an action when both happen to be under my mousepointer at the same time?
In my solution I figured that gui elements always come first. Plus, in my game it is not really needed for sprites to walk underneath gui elements while having the need for a selection, so I can kinda skip those.
With sprites versus sprites I can look up the one that's on top, so that kinda solves it too.
Hmm it's actually pretty simple now that I have written all this. :scratch:
Any other thoughts are welcomed too of course