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 works really well.

Thank you for your explanation on how this all works. I feel like I can sort out most anything in AS, but when math is involved it's humbling.

Take care everyone,
Kurt





At 04:07 PM 03/12/07, you wrote:

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, Y values to test if its offstage.

So, launching it at the right angle.....
If you think of things as a right-angled triangle, the flat bottom part of the triangle would be your X axis, while the straight side would be the Y axis. What you want is to find how much X would be given Y, or vice versa.

In trig, the tangent of an angle is the opposite side of the angle divided by the adjacent side of the angle.
Or..
Math.tan(myAngle) = myclip._y / myclip._x;

So if you knew you wanted to move it 2 pixels in the X axis each time then you'd replace with this

Math.tan(myAngle) = myclip._y / 2

Then get the unknown quantity of y on one side so we can solve for it:

Math.tan(myAngle) * 2  = myclip._y;

The tricky part is if your angle is in degree or radians. To use sine, cosine, or tangent, it must be in radians....so you gotta convert
If I remember correctly your angle in radians is myangle * Math.PI / 180.

So on every enter frame you could say....my speed horizontal speed is 2.... so myclip._x +=2; My vertical speed is determined by trig, so myclip._y += Math.tan(myangle * Math.PI / 180) * 2;

That's the gist. I didn't check ANY of this. So it might be wrong, but it's one of the ways to solve the problem.

Kurt Dommermuth wrote:
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 stops.

the speed is fixed.  there is no gravity.

How do I determine the _x and _y value somewhere off stage?

I'd appreciate any help. even if someone could let me know what to search for.

thank you!

Kurt

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to