Page 1 of 1
Avoid Collision
Posted: Thu Aug 16, 2012 1:50 pm
by Surbhit29
I have two draggable objects. I want both the objects to move as I drag them but I don't want them to collide or get overlap. Also how is it possible to drag them inside another object limiting their path...?
For eg, I want to Drag two square inside a Circle but I don't want both the square to collide or to overlap. Also the path of the squares should be limited inside the circle.
Re: Avoid Collision
Posted: Thu Aug 16, 2012 4:23 pm
by shaosean
Check out the demo of Animation Engine.. Malte has pretty much covered everything in there and made a pretty simple API to use and will save you countless time units spent figuring it out yourself.. But that being said, take a look at the
is within operator, the
location property (this will be the center point of the object so you can use it to keep your objects on a path which you might sent using one of the draw tools) and the
move command.. Now each of those has a list of "see also" that you should check out.. After learning those commands you will still need to write your math and anything else required to do what you need it to do (you can see why I just recommend Animation Engine

)
Re: Avoid Collision
Posted: Fri Aug 17, 2012 5:41 am
by Surbhit29
I have gone through the manual of Animation engine but it only says about detecting collision. How to stop collision between two objects. Please send me the link if you have any. Thanks for the reply.
Re: Avoid Collision
Posted: Fri Aug 17, 2012 8:40 am
by Surbhit29
Can you send me the link of that demo by Malte...?
Re: Avoid Collision
Posted: Fri Aug 17, 2012 9:18 am
by shaosean
From reading your other posts, you already have it..
Re: Avoid Collision
Posted: Wed Aug 22, 2012 7:58 am
by Surbhit29
I tried to use "is within" operator but it is showing the error "Operators is: right operand of within is not a rectangle near 140"
This my script
Code: Select all
on mouseDown
grab me
point "248, 215" is within 140, 108, 356, 322
end mouseDown
Is it ok?
Re: Avoid Collision
Posted: Wed Aug 22, 2012 8:20 am
by LittleGreyMan
Hi,
Sorry to be harsh, but RTFM!

It will require less time then posting here and you will learn
a lot!
The Dictionary example for within is:
Do you notice anything?
HTH
Re: Avoid Collision
Posted: Wed Aug 22, 2012 8:42 am
by Surbhit29
Already tried that. But it gives an error" bad command"
Re: Avoid Collision
Posted: Wed Aug 22, 2012 8:59 am
by LittleGreyMan
Really? Are you sure you *exactly* tried that?
If I type:
Code: Select all
answer ("248, 215" is within "140, 108, 356, 322")
in the message box, LC returns true. I copied and pasted from your post, just added the quotes.
HTH
Re: Avoid Collision
Posted: Wed Aug 22, 2012 1:26 pm
by Klaus
Hi Surbhit29,
Surbhit29 wrote:Already tried that. But it gives an error" bad command"
Because you are using it inside of your "mousedown" handler without any "put" or "get" or "answer" or whatever!
And that does not make any sense and is in fact a "bad command".
Do yourself a favour and check the basics of Livecode with the help of these stacks:
http://www.runrev.com/developers/lesson ... nferences/
Best
Klaus
Re: Avoid Collision
Posted: Wed Aug 22, 2012 2:18 pm
by Surbhit29
Thnx Klaus...
