Drag and drop images

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
chariscomp
Posts: 2
Joined: Mon Jun 26, 2006 1:46 pm

Drag and drop images

Post by chariscomp » Tue Dec 12, 2006 7:15 pm

Hello, I am new to Revolution. I have a copy of Revolution Media and am interested in making a card game with it. I want to be able to have cards and drag them around on the screen. I have looked at the drag and drop sample included in the system, but it doesn't show the image of the color swatch when dragging. I want to be able to drag a card and see it the whole time I am dragging it. I plan to use buttons for the cards as I have figured out how to add pictures to the buttons. Does anyone have any suggestions about this subject? I realize there may be a more efficient way, but that's as far as I have gone.

Thanks for any help!

Joshua

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Tue Dec 12, 2006 8:18 pm

HI Joshua,

could you please be more specific of what you want to drag where? Do you want to drag elements within a window? If so you might want to try the grab command.

In a button script:

on mouseDown
grab me
end mouseDown

If something like this is what you are after, you might want to constrain the area your card images might be dragged in. In that case I can provide a more sophisticated script.

Concerning images in buttons: What you are after is the icon property:

set the icon of button "myButton" to the ID of image "myImage"

hope that helps,

Malte.

PS: you might be interested in the free eBook I wrote, which is available on my homepage:

http://www.derbrill.de/tutorials_e.html

chariscomp
Posts: 2
Joined: Mon Jun 26, 2006 1:46 pm

Thanks!

Post by chariscomp » Tue Dec 12, 2006 11:02 pm

Malte,

This did the trick! I am interested in your additional information for constraining where the button can be moved. Also, how hard would it be to add the ability to snap to a certain area? A lot of card games that I have seen will snap the card into a nice neat pile if you just get it close. Thanks for all of your help!

Joshua

Post Reply

Return to “Talking LiveCode”