PDA

View Full Version : AS motion tween



vinnepin
September 17th, 2003, 07:03 PM
Hey guys,

I got a question for u.

I have studied the tutorial on springs but i want to make something my own but i just cant figure it out :(.

Here's the deal:

Lets say i have 2 menu items, 1 on the top and 1 at the bottom. And lets say there is a button to say it may go moving.
When u press the button the menu at the bottom is going to move to the spot where menu at the top is.
But the problem with this is that i want it to deaccelerate when it comes closer at the menu at the top.

I have figured out how to use the mouse follower with deacceleration :
onClipEvent(enterFrame) {
if (moving) {
Xspeed = _xmouse/20;
Yspeed = _Ymouse/20;
this._x+=Xspeed;
this._y+=Yspeed;
}
}

But i cant seem to figure out how to use this code on the menu :(

Do u know how??

jingman
September 17th, 2003, 09:03 PM
read the tutorials here about elasticity/physics for good movement code.

vinnepin
September 18th, 2003, 12:54 AM
Yes i have already studied this tut. But i just cant seem to figure this one out :(

Lews
September 18th, 2003, 01:20 AM
I think this will work.



onClipEvent(enterFrame) {
if (moving) {
//NewX/NewY are the new _x and _y locations to where the menu should move.
Xspeed = _xmouse/20;
Yspeed = _Ymouse/20;
this._x+=(NewX-_x)/Xspeed;
this._y+=(NewY-_y)/Yspeed;
}
}

vinnepin
September 18th, 2003, 01:51 AM
Yes that works for me :D

stupid me to forget NewX-_x :P