Page 1 of 1

Object drag inside a circle

Posted: Fri Aug 17, 2012 6:29 am
by Surbhit29
I have an object Rectangle and it is draggable. The object is inside a circle. How can I restrict the path of the rectangle inside the circle, i.e the rectangle cannot be drag outside but within the circle.
Please tell me the code..

Re: Object drag inside a circle

Posted: Fri Aug 17, 2012 7:22 am
by malte
For a rectangle this is a little tricky. what you can do is constrain it in a way that can check if the location of your object (the middle point) is still within the circle. Would that help?

Re: Object drag inside a circle

Posted: Fri Aug 17, 2012 7:36 am
by Surbhit29
I already tried that, but it didn't help. What if I use a rounded rectangle such that it matches the circumference of the circle. Can you help now..?
Also I am new at it. It will be great if you can post code for it.

Re: Object drag inside a circle

Posted: Fri Aug 17, 2012 7:59 am
by Surbhit29
Also can it help if I use collision detection.. And then prevent the collision to occur

Re: Object drag inside a circle

Posted: Fri Aug 17, 2012 4:58 pm
by malte
Well, if you say you did that, it would be helpful if you told us what you tried. :-)

Re: Object drag inside a circle

Posted: Sat Aug 18, 2012 2:58 pm
by Surbhit29
Actually I just followed the steps that came in Animation Engine 5 tutorial padf... ;)
Created 6 graphics, a label field and a button.... Now the first object that was created when collide with any of the five objects the label field shows the detection.....