PDA

Click to See Complete Forum and Search --> : angle movement ?



fuad_all
10-31-2002, 09:30 AM
i want to move a movieClip from one point other by an angle..
anybody knows how it can be done ?

bit-101
10-31-2002, 11:40 AM
first decide the angle.
then decide the speed.
then convert the angle to radians.
take cosine of angle (in radians) and multiply by speed.
that's your x speed.
take sine of angle and multiply by speed.
that's your y speed.
add x and y speed to _x and _y position.



angle=53;
speed=5;
rad=angle*Math.PI/180;
xspeed=Math.cos(rad)*speed;
yspeed=Math.sin(rad)*speed;
yourclip._x+=xspeed;
yourclip._y+=yspeed;


repeat last two steps for continued motion.

BlinkOk
10-31-2002, 11:52 AM
you can do it using localToGlobal() as well;
http://www.nlc.net.au/~oceana/games/localGlobalMove.swf
http://www.nlc.net.au/~oceana/games/localGlobalMove.fla

fuad_all
11-01-2002, 10:04 AM
thanx guys..but this not what i want..:)
i want mc to stop on an exact point..
thanks anyway...

BlinkOk
11-01-2002, 10:09 AM
click anywhere in the window;
http://www.nlc.net.au/~oceana/games/follow.swf
http://www.nlc.net.au/~oceana/games/follow.fla

fuad_all
11-01-2002, 10:24 AM
i appologise..your code is cool, but i want the mc moves from 10|10 to 250|300
by angle=30.