Here's the vector math solution:
Get the vector from the mouse to the MC:
var vToMouse:flash.geom.Point = new
flash.geom.Point();
vToMouse.x = MC._parent._xmouse - MC._x;
vToMouse.y = MC._parent._ymouse - MC._y;
Normalize the vector. This means you set the length of
the vector to 1.
var vectorL
Some simple Trig actually.
As an example, name a movieClip "myClip" and rotate it. Then add this code
to the frame.
this.onEnterFrame = function(){
rads = myClip._rotation * (Math.PI/180);
myClip._x += Math.sin(rads);
myClip._y -= Math.cos(rads);
}
That should get you started.
By the
Thank you all.
My assistant actually pointed out a very simple way to accomplish what I
wanted to do.
He suggested just adding another mc called "targ" off the stage. "targ"
rotates with the projectile I'm firing. when the user clicks I just tell
the projectile to go to the target mc.
It
Its trig, no calculus.
Basically you want a point off stage that the clip would pass through
because it's pointing in that direction right?
Are you using the tween classes? If so you'll probably need a X,Y
coordinate. If not, you could simply move your MC at the correct angle
and use the X,
: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] trig? calculus? put me out my misery
Hi all,
I have what I initially thought was simple problem, but I've been racking
my brains, searching the web and I just don't get it.
I have a movieclip that the user can rotate .
When they
calculate the
motion in question.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kurt
Dommermuth
Sent: Monday, March 12, 2007 1:30 PM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] trig? calculus? put me out my misery
Hi all,
I have what I
Hi all,
I have what I initially thought was simple problem, but I've been racking
my brains, searching the web and I just don't get it.
I have a movieclip that the user can rotate .
When they click the movieclip shoots off in the direction it's pointing.
It's goes off the stage and simply st
7 matches
Mail list logo