Avoid Collision

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

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Avoid Collision

Post by Surbhit29 » Thu Aug 16, 2012 1:36 pm

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.

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

Re: Avoid Collision

Post by malte » Thu Aug 16, 2012 4:05 pm

i,

is this for desktop or mobile? Or both?

All the best,

Malte

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Avoid Collision

Post by Surbhit29 » Fri Aug 17, 2012 5:34 am

For mobile.. Can you help..? I even tried animation engine. It only detects collision. But how to prevent collision from happening.

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

Re: Avoid Collision

Post by malte » Fri Aug 17, 2012 7:21 am

Hi,

well, if you detect the collision you are half way there. :-) You will have to respond to the collision event. This requires a little scripting though. I can try to whip something up after the weekend.

All the best,

malte

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Avoid Collision

Post by Surbhit29 » Fri Aug 17, 2012 7:39 am

I am able to detect collision. But since I am new at it, I am not able to understand what to do after detecting collision. It would be great if you post the script.
Thnx a lot... :D

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

Re: Avoid Collision

Post by malte » Fri Aug 17, 2012 5:11 pm

Hi surbhit,

even though I would be able to maybe post a working solution, I am not too sure if it would help you with your learning curve. Do not get me wrong, it is not that I am unwilling to do so, however if you are new to liveCode, or even coding in general, I must insist that you have the basics right. Collision response is a rather tricky topic and even though AE makes life a little easier for you, you will need to have the basics of liveCode coding. Yur example you want to achieve is a rather tricky one, as you will need to check quite a few factors and that requires writing quite a bit of code still. If you have coding experience already, I might be able to give some pointers, if you do not you will really have to get the basics down first.

Especially you will need to understand what messages are and how they travel along the message path. Once you got the liveCode basics down, the AE documentation will give you a lot of pointers on how to solve problems such as collision response. If you rely on the constraining methods in AE, you will have to trap the touchMove message for mobile and the mouseMove message on the desktop. In certain conditions you will want to let these messages pass (most likely based on the distance function in AE or with a selfmade distance function). Right now I am afraid I do not have the time to post a working solution. I might get around to that at some point within the next few days, but I can nbot promise that, as my company is pretty packed with paid for development at the moment. I hope that is understandable.

All the best,

Malte

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Avoid Collision

Post by Surbhit29 » Sat Aug 18, 2012 5:40 am

Hi Malte
Thanks for the reply. Actually I 've been working on livecode for only few days, infact this is my 5th day. So you can know that I don't have much of knowledge in programming in livecode. I do understand the concept of message path, and other basic stuff. But I don't know much of command and functions and syntax about it.
I will go through to the basic stuff of it. Can you just send me the link from where I can start learning the programming from the scratch. I've browsing internet but just learning live code in parts. It will be great if you tell me how to start my basic in programming in livecode. Also how will it take to learn basic programming given that I am spending 8hours on it.

Surbhit

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Avoid Collision

Post by Surbhit29 » Mon Aug 27, 2012 9:05 am

Hi Malte
I've been working on avoiding collision technique and I am able to figure out an command in which when two objects intersect a message is displayed which tells us that the two objects have been collided. But the problem is both the objects can be dragged randomly. So how is it possible to make the drag stop when one object comes in front of another so that they don't get overlap or get collided.

Surbhit

Post Reply

Return to “Animation Engine”