britzl / defold-input

Simplify input related operations such as gesture detection, input mapping and clicking/dragging game objects
MIT License
111 stars 26 forks source link

Request: Example of a "dropzone" for detecting whether a game object is over a set of coordinates #29

Closed sominator closed 1 year ago

sominator commented 1 year ago

Hi there,

I'd like to request an example of a dropzone that would detect whether a game object (e.g. playing card) is over a particular area while being dragged with the cursor.

Presumably, the dropzone and game object(s) would use colliders to determine when the game object is over the dropzone. Ideally, there would be a simple API that could return info about the state of the drag event, like isOverDropZone = true, wasDropped = false, etc. This would allow for things like returning the game object to its starting coordinates if it wasn't placed over a dropzone, or disabling its draggable functionality if it was placed correctly.

Thank you!

britzl commented 1 year ago

@sominator I've added a dropzone example where you sort green and blue aliens into two same colored dropzones. It should hopefully help you get going with your own similar solution.

sominator commented 1 year ago

@britzl this is so excellent and exactly what I was looking for. Thank you so much for taking the time to create it!