How do I know if one object is within another object?

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

How do I know if one object is within another object?

Post by genie » Fri Oct 24, 2014 5:33 am

Good day y'all!


I have a question...

How do I know if one object is within another object? (that they fully overlap)

I know "intersect", but it only tells when 2 objects collide, right?

Also, "within" only tells if a point is within an object, not object within the object.

Can't seem to find what to use.


And another question...

How do I tell if one object directly beside another object? By object, I mean controls with irregular shape. You can think of like I am trying to assemble pieces of something and I like to know if 2 pieces are connected. By connected I mean to say there shouldn't be any hollow/empty pixel between the two.


Thank you so much!


Any insights will be greatly appreciated.


Regards,
Genie

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: How do I know if one object is within another object?

Post by jmburnod » Sat Oct 25, 2014 12:15 pm

Hi Genie
How do I know if one object is within another object? (that they fully overlap)
Also, "within" only tells if a point is within an object, not object within the object.
You can use within for each point of your object. Points if this is an irregular polygon or topleft,topright... if this is an other object
Best regards
Jean-Marc
https://alternatic.ch

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: How do I know if one object is within another object?

Post by genie » Sun Oct 26, 2014 3:46 pm

jmburnod wrote: You can use within for each point of your object. Points if this is an irregular polygon or topleft,topright... if this is an other object
Ohh, i see. Sound tedious...but thank you so much for your help jm. :) Now I know what to do!

Regards,
Genie

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: How do I know if one object is within another object?

Post by jmburnod » Sun Oct 26, 2014 4:51 pm

Now I know what to do!
Yes for the first part but what about the second ?
How do I tell if one object directly beside another object?
:D
Best regards
Jean-Marc
https://alternatic.ch

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: How do I know if one object is within another object?

Post by newtronsols » Sun Oct 26, 2014 5:16 pm

you could have invisible objects next to the visible - like a boundary. Then test for intersect e.g. a slightly larger invisible outer circle or a slightly larger invisible outer box.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How do I know if one object is within another object?

Post by FourthWorld » Sun Oct 26, 2014 5:31 pm

I stumbled across a function from the use-livecode list for this:
http://lists.runrev.com/pipermail/use-l ... 61156.html
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Games”