engo icon indicating copy to clipboard operation
engo copied to clipboard

MouseSystem detect transparency

Open EtienneBruines opened this issue 9 years ago • 8 comments

It would be nice if the MouseSystem detected transparency, and had an option to let it "not fire" an event whenever you hover the transparent background.

Use-case: you have a red circle with transparent background. On hovering, you want the cursor to change. You want the cursor to change only whenever you hover the red part, not the transparent background.

EtienneBruines avatar Apr 19 '16 20:04 EtienneBruines

I don't think this should be the game engine's responsibility rather than the user. If you have a circle regardless of what's inside of it, when the mouse hovers above it it should fire the mouse hover event. If you have a circle object there should be a way to define where it collides as well (edges).

otraore avatar Apr 19 '16 21:04 otraore

We should be able to handle circular objects in some way or the other. The MouseSystem has an "easy" fix in that you can detect the transparency-level of the current pixel within the texture you're hovering. Not sure how fail-proof that is with rotation in place. The CollisionSystem would indeed be even harder.

But when we offer a MouseSystem or CollisionSystem (which we do), we should at least try to make them work with circular objects (or at least leave this issue open because we don't know how to fix it).

EtienneBruines avatar Apr 19 '16 21:04 EtienneBruines

@EtienneBruines I understand but you are taking some extensibility from the user whereas they could handle it themselves. How about in the event somehow let them now if the collision was a transparent hover, I haven't looked into the messaging/event system that much so I'm not sure how yet.

otraore avatar Apr 19 '16 21:04 otraore

Well, the "event firing" is currently a matter of setting entity.MouseComponent.Hover to true.

We could optionally allow them to set CheckForTransparency or something when adding the MouseSystem, which would be more strict than the current implementation.

EtienneBruines avatar Apr 19 '16 21:04 EtienneBruines

Sure @EtienneBruines sounds good

otraore avatar Apr 19 '16 21:04 otraore

Hmm, everything (including the current implementation with squares, not to even begin about circles) breaks with rotation (#216), this is gonna need some more thought than I hoped...

Up for grabs :)

EtienneBruines avatar Apr 19 '16 21:04 EtienneBruines

@EtienneBruines Wouldn't rotation with circles be easier lol?

paked avatar Apr 21 '16 00:04 paked

@paked Lol, yes, if you rotate around the center. Which we don't do yet.

EtienneBruines avatar Apr 21 '16 13:04 EtienneBruines