Is there a way to add collision detection between layers? For example, if there are 2 circle layers which are draggable within the canvas, can we do something that they do not intersect each other, but instead bounce off when they collide?
11 Comments
Benjamin Den Boer
Yes! Eelco Lempsink is your man for this. ;-)
Dave Crow
Following
Brent Riddell
Also following ...
Misha Scholte
Perhaps you can check the x & y values of both the layers. If they are the same, bounce
Josh Ackerman
To provide an alternative solution, you can use force layouts and D3.js to achieve this.
Kevyn Arnott
The big challenge is limiting the calculations that need to be performed. This is one way to do it. Drag the boxes, and when they touch they'll turn red – http://share.framerjs.com/7v939uur00j7/
Thanks Eelco! Ideally, I'd like to be able to create simulations like the ones I have created here - http://dhruv.work/Kin And the combine them with gravity using the phone's accelerometer. The dating app - "happn", uses something very similar.
11 Comments