T
tukib
Guest
Hey guys. I've been relentlessly searching on the internet, but I haven't found any solution. As the title says, I want a pixel perfect click detection system.
Ideally, for an object to be activated, it needs to be clicked on. This results in an inventory opening, or a machine turning on, et cetera.
What I'm looking for is an object being activated only when the mouse has been clicked, and the mouse is directly above a pixel of that object's sprite. An example would be clicking in the hole of a doughnut sprite. The object will not be activated, because the inside of the sprite is hollow - there are no pixels belonging to that sprite.
In addition to this, if there are multiple objects, only the topmost object that can be clicked on should be activated.
I've taken a sprite from a quick google image search and edited it to show where clicks cause the object to activate (green: activate, red: nothing)
If you still don't understand what I'm trying to figure out, take a look at the BYOND engine and how 'click procs' work. That engine in particular coincidently is almost exactly what I want to achieve.
Ideally, for an object to be activated, it needs to be clicked on. This results in an inventory opening, or a machine turning on, et cetera.
What I'm looking for is an object being activated only when the mouse has been clicked, and the mouse is directly above a pixel of that object's sprite. An example would be clicking in the hole of a doughnut sprite. The object will not be activated, because the inside of the sprite is hollow - there are no pixels belonging to that sprite.
In addition to this, if there are multiple objects, only the topmost object that can be clicked on should be activated.
I've taken a sprite from a quick google image search and edited it to show where clicks cause the object to activate (green: activate, red: nothing)
If you still don't understand what I'm trying to figure out, take a look at the BYOND engine and how 'click procs' work. That engine in particular coincidently is almost exactly what I want to achieve.