Sticking an image to the cursor

Colin Holgate coiin at rcn.com
Sat Oct 11 13:14:07 EDT 2008


On Oct 11, 2008, at 11:00 AM, Sue Smith wrote:

> Is is possible for an image to smoothly "stick" onto the cursor? I  
> am working on a jigsaw puzzle for children. I know that I can set  
> the image to the mouse location, but it is very choppy and and the  
> image will drop if the user accelerates mouse speed and it can't  
> leep up.


I imagine you're using mousewithin, or something like that? You can do  
all the dragging control in the card script. I probably haven't done  
this in the most advanced way, but it works, this will make anything  
you drag follow the mouse:

on idle
    global dragging,dx,dy,dragwhat
    if dragging then
       set the loc of dragwhat to the mouseh - dx,the mousev - dy
    end if
end idle

on mouseDown
    global dragging,dx,dy,dragwhat
    put true into dragging
    put the target into dragwhat
    put the clickh - item 1 of the loc of the target into dx
    put the clickv - item 2 of the loc of the target into dy
end mouseDown

on mouseUp
    global dragging
    put false into dragging
end mouseUp

Of course, you might check to see what is being clicked on to limit it  
to jigsaw pieces, maybe by checking the name.





More information about the use-livecode mailing list