Building a Board Game

Devin Asay devin_asay at
Tue Apr 7 15:48:16 EDT 2020


Rather than moving an object, think about using button icons.  This is the basic process:

- on mouseDown: check the icon of the target, set the icon of a hidden, moving button to the same icon, set the icon of the target to 0, set a flag—isDragging--to true, show the hidden button

- on mouseMove: if isDragging is true, set the loc of the moving button to the mouseLoc

- on mouseUp: figure out which square you’re over, set the icon of that button to the icon of the moving button, hide moving button, set isDragging to false.

I made a rudimentary chess game that uses this technique, check it out here:

Click the Clear Board and Setup Game buttons first to set up the game board array. Game state handlers are in the card script; game piece moving handlers are in the game board group script.

Hope this helps.


On Apr 7, 2020, at 1:24 PM, Roger Guay via use-livecode <use-livecode at<mailto:use-livecode at>> 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?

Thanks much,

use-livecode mailing list
use-livecode at<mailto:use-livecode at>
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

Devin Asay
Office of Digital Humanities
Brigham Young University

More information about the use-livecode mailing list