Thank you, Quentin. I’ll give it a try. Roger
> On Apr 10, 2020, at 4:03 PM, Quentin Long via use-livecode > <use-livecode@lists.runrev.com> wrote: > > On 7.04.20 22:24, Roger Guay via use-livecode wrote: >> Hi all, >> >> I know there must be a simple way to do this but it is escaping me at the >> moment. How can I move an object (grab me on mouseDown) and have it snap to >> a grid (square on a board game) on mouseUp? > There are any number of ways to do this thing. Try giving this script to the > object you want to move: > local DisX, DisYlocal GridSize = 20-- if grid uses different sizes for X and > Y, make GridSizeX and GridSizeYlocal OriginGridX = 10local OriginGridY = 10 > on mouseDown send "TrackDaMouse" to meend mouseDown > on TrackDaMouse put the mouseLoc into Fred put GridSize * ((item 1 of Fred > - OriginGridX) div GridSize) + OriginGridX into DisX put GridSize * ((item 2 > of Fred - OriginGridY) div GridSize) + OriginGridY into DisY set the loc of > me to Fred if the mouse is down then send "TrackDaMouse" to me in 20 msec > else move me to (DisX, DisY) in .5 seconds end ifend TrackDaMouse > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode