junkdog / artemis-odb

A continuation of the popular Artemis ECS framework
BSD 2-Clause "Simplified" License
769 stars 109 forks source link

[Question] How do you handle clicks on nothing? #622

Closed bryanbrunt closed 3 years ago

bryanbrunt commented 3 years ago

So I have the MouseClickSystem working. It handles Clickable.Class and Pos.Class.

However, I want to be able to handle mouse clicks that are not associated with any object. Yes, inside of MouseClickSystem, I can test to see if the cursor is not overlapping any Clickable entity, but that is potentially hundreds or thousands of entities. And it would consume processing for each mouse click.

A listener based mouse system which I assume many games use doesn't have this issue.

Is there an easy method to detect if the click occurred for example on the TileMapped but not a Clickable.Class?

bryanbrunt commented 3 years ago

I came up with a solution. Just set a boolean in the process method if no entities overlap, and then handle the condition in the end method.