Execute command for any button touching a button?

Create fast, sprite powered games with Animation Engine, co-developed with DerBrill Software!

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
ColdSnap
Posts: 7
Joined: Thu Mar 24, 2011 10:23 pm

Execute command for any button touching a button?

Post by ColdSnap » Thu Apr 21, 2011 12:21 am

Using the command line

Code: Select all

 if circleCollide(the loc of btn "myButton1",the loc of btn "myButton2",41) then
I can execute an if/then command for two static buttons. Is there a way for this to be more variable?

Something along the lines of

Code: Select all

 if circleCollide(the loc of btn "myButton1",the loc of any other button,41) then

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Execute command for any button touching a button?

Post by Dixie » Thu Apr 21, 2011 12:46 am

Hi...

Have a look at 'intersect' in the dictionary

be well

Dixie

ColdSnap
Posts: 7
Joined: Thu Mar 24, 2011 10:23 pm

Re: Execute command for any button touching a button?

Post by ColdSnap » Thu Apr 21, 2011 1:28 am

Dixie wrote:Hi...

Have a look at 'intersect' in the dictionary

be well

Dixie
This seems like an excellent solution, tyvm.

ColdSnap
Posts: 7
Joined: Thu Mar 24, 2011 10:23 pm

Re: Execute command for any button touching a button?

Post by ColdSnap » Thu Apr 21, 2011 8:03 pm

Ok Dixie, I have given intersect a shot, and the problem here is that the buttons in question are not actually overlapping, but rather side by side.

Can I define how close together the objects have to be to be considered intersecting?

In stupid talk, I would like to do something like

Code: Select all

set the intersect to -10
so that buttons which are within ten pixels are considered intersecting.

If I cannot do that I suppose I can add invisible edges to that the buttons intersect without looking like they do.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Execute command for any button touching a button?

Post by Dixie » Thu Apr 21, 2011 10:48 pm

Coldsnap...

Would this work for you ?... Make your button say, 60 x 60 pixels, make a graphic 80 x 80 and place it over the button ... Set the line size of he graphic to 0, then it will not seem like there was anything around the button... group the button and the graphic. The edge of the group would then give you the 10 pixel margin that you are looking for from the edge of the button.

If you then have two button 'groups', you can then use the intersect function to find out if they are 'colliding'.

Code: Select all

 if intersect (group "buttonGroup 1", group "buttonGroup 2") then doSomething
be well

Dixie

Post Reply

Return to “Animation Engine”