Drop target detection using physics engine (Matter.js, Drag & Drop)

Demo:
DropTargetDetectionUsingMatter.html

Source:
DropTargetDetectionUsingMatter.hype.zip

Have fun! Should be great for games!

PS: This is about the detection and works with multiple irregular shapes by setting them to a static physics object. This technique is pretty simple and works perfect as is, but I still am planning to convert it into an extension in the next few days to avoid the additional function call on dragged elements. The example linked is only a quick way to use drop targets but it works with multiple drop targets and what ever logic your game/app needs.

3 Likes