Finding name of an image I just dropped another image on

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Livecoder
Posts: 6
Joined: Tue Feb 18, 2014 4:23 pm

Finding name of an image I just dropped another image on

Post by Livecoder » Sun Aug 24, 2014 5:33 pm

Hi everyone. I am developing a game in which you can drag and drop different images around the screen using

Code: Select all

grab
I have image "Red" and i want to know the name of the image i just dropped it on without having to have a whole heap of code manually checking each possibility. Any ideas on how I could go about this?

Thanks
Livecoder

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Finding name of an image I just dropped another image on

Post by Simon » Sun Aug 24, 2014 7:28 pm

Hi Livecoder,
That was FUN!
Without a ton of code use a repeat loop and check if the loc of img "RED" (more robust if you say the loc of me) "is within" the rect of one of the other images.

OK so that is very cryptic, but see if you can figure out what I'm talking about. I did it in 9 lines.
If you still have trouble just ask :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Re: Finding name of an image I just dropped another image on

Post by sritcp » Sun Aug 24, 2014 9:10 pm

Hi Livecoder:
Put the following code in the card script:

Code: Select all

global gTheObjectUnder

on mouseEnter
put the name of the target into gTheObjectUnder
end mouse Enter

on mouseLeave
put empty into gTheObjectUnder
end mouseLeave
The global will contain the name of the underlying object (until the mouse leaves the object).

Regards,
Sri

Post Reply