Object resize when dragged into another object

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

Moderators: heatherlaine, robinmiller, kevinmiller, malte

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

Object resize when dragged into another object

Post by Surbhit29 » Fri Aug 17, 2012 10:19 am

I have an object Rectangle and another rectangle smaller than previous one. What I want is when I drag the larger Rectangle on smaller rectangle the larger rectangle changes it size into the smaller rectangle and is rested upon the smaller one. But in the end both of are of same size. With one rectangle over the other.
Or in simple words... can an object's size be changed after it is drag at a particular location.
Is it possible...??

shaosean
Posts: 905
Joined: Thu Nov 04, 2010 7:53 am

Re: Object resize when dragged into another object

Post by shaosean » Fri Aug 17, 2012 2:17 pm

yes.. You can either set the width and height properties, or (even easier) set the rectangle property.. setting the rectangle property will cause the control to get the same dimensions, as well as moving it to overlap with the other control

Code: Select all

set the width of control "a" to (the width of control "b")

Code: Select all

set the rectangle of control "a" to (the rectangle of control "b")

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

Re: Object resize when dragged into another object

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

And in animationEngine there is even a handler to do so (and animating it even). Please read the documentation on aeChangeRect.

shaosean
Posts: 905
Joined: Thu Nov 04, 2010 7:53 am

Re: Object resize when dragged into another object

Post by shaosean » Sat Aug 18, 2012 8:33 am

You have thought of everything in there haven't you? ;-)

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

Re: Object resize when dragged into another object

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

Thanks a lot..... Malte and Shaosean....
It worked.... I used Animation Engine
Just one more thing.... Can same thing be done for Polygon....???
Is their any command like "aeChangePolygon"
What if I want to drag the Polygon into another polygon of different size....

Also what if I had to do a vice-versa of this.... Bringing the rectangle back to its original shape by dragging...
Last edited by Surbhit29 on Sat Aug 18, 2012 2:49 pm, edited 1 time in total.

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

Re: Object resize when dragged into another object

Post by malte » Sat Aug 18, 2012 2:39 pm

Hi,

Changing the rect for a polygon should just scale it nicely. However it is adviseable to remember the original points of the poly (if it is not a regular poly)

cheers,

Malte

@Shao: almost ;-)

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

Re: Object resize when dragged into another object

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

Hi Malte..

I want to drag a Polygon into another Polygon..... Not a rectangle into Polygon.....
How can that be done...?

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

Re: Object resize when dragged into another object

Post by malte » Sat Aug 18, 2012 7:43 pm

Hi,

first of all, you need the logic when the drag is considdered being a valid drag. :-) This might be if the location of the poly is inside the area of the other poly, or already when both polys collide. Once you decided when you considder a drag being valid, you still can work with the rect property. Each control has a (bounding) rectangangle. So assuming both polys have the same shape you coud do a

set the rect of grc "aPoly" to the rect of grc "bPoly"

or use aeChangeRect to do it with a little animation.

Hth,

Malte

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

Re: Object resize when dragged into another object

Post by Surbhit29 » Sun Aug 19, 2012 2:23 pm

Hi Malte..
Polygon is outside another polygon... I want to drag the polygon which is outside into another polygon... And when dragged inside.. The polygon which is outside changes its size and fit in the second polygon...
How can it be done using aeChangeRect..?

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

Re: Object resize when dragged into another object

Post by malte » Mon Aug 20, 2012 1:43 pm

aeChangeRect the long ID of grc "outerPoly",the rect of grc "innerPoly",tTimeInMillisecs

All the best,

Malte

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

Re: Object resize when dragged into another object

Post by Surbhit29 » Tue Aug 21, 2012 5:56 am

Hi Malte
It is showing an error, "handler can't find handler near aeChangeRect"

shaosean
Posts: 905
Joined: Thu Nov 04, 2010 7:53 am

Re: Object resize when dragged into another object

Post by shaosean » Tue Aug 21, 2012 9:13 am

Is animationEngine loaded?

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

Re: Object resize when dragged into another object

Post by Surbhit29 » Tue Aug 21, 2012 2:36 pm

Ooopsss.... ;)

shaosean
Posts: 905
Joined: Thu Nov 04, 2010 7:53 am

Re: Object resize when dragged into another object

Post by shaosean » Tue Aug 21, 2012 7:34 pm

Happens to the best of us ;)

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

Re: Object resize when dragged into another object

Post by Surbhit29 » Wed Aug 22, 2012 7:16 am

Thnx Malte and Shaosean.....
You guys are helping me a lot..

Post Reply

Return to “Animation Engine”