Fridge Magnets

Hi all, just starting out with Box2D, good fun so far though!

I'm attempting to make a little program where a user can drag elements around, and was planning on using Box2D to handle the interaction between the elements (collisions). If you imagine someone dragging around and re-ordering magnets on a fridge, that's pretty much the effect I'm after - where you can drag elements but they stop when you stop dragging.

I'm modifying the HelloWorld example, but I can't figure out how to achieve this effect. Initially I'd assumed I'd have to create a shape to represent the 'fridge door' upon which the magnets would rest, but the few attempts I've had so far didn't work. Next I tried turning off gravity to stop the 'magnets' dropping down to the bottom, with the inevitable consequence that objects keep moving after they're released (d'oh).

Any help/pointer as to how I could go about this appreciated! 😉
You could try to set the body's velocity to zero when you release it.
You could also just set some really high level of damping (near 100%).
Kennyan wrote:
You could try to set the body's velocity to zero when you release it.

Gave this a shot, and got it to work reasonably well, thanks for the idea.

brainclog wrote:
You could also just set some really high level of damping (near 100%).

Magic, exactly what I was after. Thanks brainclog!

Original thread: https://box2d.org/forum/viewtopic.php?t=725