Object drag inside a circle

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

Moderators: heatherlaine, robinmiller, kevinmiller, malte

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

Object drag inside a circle

Post by Surbhit29 » Fri Aug 17, 2012 6:29 am

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..

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

Re: Object drag inside a circle

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

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?

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

Re: Object drag inside a circle

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

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.

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

Re: Object drag inside a circle

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

Also can it help if I use collision detection.. And then prevent the collision to occur

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

Re: Object drag inside a circle

Post by malte » Fri Aug 17, 2012 4:58 pm

Well, if you say you did that, it would be helpful if you told us what you tried. :-)

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

Re: Object drag inside a circle

Post by Surbhit29 » Sat Aug 18, 2012 2:58 pm

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.....

Post Reply

Return to “Animation Engine”