V
V
Vasily Demin2016-02-05 19:48:32
C++ / C#
Vasily Demin, 2016-02-05 19:48:32

How to drag and drop multiple objects with collisions?

I need to do drag'n drop with collisions.
I have two rectangles, one of which is moved by the mouse on the screen.
f98aa3c29bc644419e449ba87bbc5b48.png
I need to make it so that when it collides with another rectangle, the following happens:
Depending on the side it collided with, its location was chosen. Let's say rectangle 1 collides with the left side of rectangle 2. 34823e78e999472ebba046b198e65a9b.png
We need to move it to the left so much that it becomes close to rectangle 2, the same should happen with the other sides, while we can also move rectangle 2 with the mouse.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2016-02-05
@IonDen

You should use paper.js, it can count collisions.
paperjs.org/examples/candy-crash

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question