Snap to it

Hans-Martin Mosner hmm at heeg.de
Tue Jan 15 19:19:56 UTC 2002


"David N. Smith (IBM)" wrote:

> Does anybody know any slick ways for assembling morphs by dragging one close to another and having it snap into place? The dragged morph might even become a submorph of the item it is dragged to, and certainly the assembled morphs are one entity of some kind and can themselves be dragged near yet another morph and snap into place.
>
> I have an ugly solution that usually works. I'm hoping that someone else has an elegant one.

I've implemented a jigsaw puzzle game which does it. Basically, each piece knows its correct neighbors and connects to them if it is sufficiently close to any of them. Whether it's elegant, I don't know. It simply works :-)
In your case, each piece would need to check against all neighbors in its proximity, since it could probably connect to any other morph (of certain kinds, of course).
What does your solution look like?





More information about the Squeak-dev mailing list