-
Point at MC help...
I seriously need some help with this. I am making a game and i don't know how to make the a movieclip point or turn into the direction of another movieclip. In the game you will be able to drive a car and at some points the cops follow you. How do you make them follow your car movieclip and how do you do it that the cop car points into the direction of the car...?
Thanks for your help....
-ROFLMASTER
-
you'll need quite a bit of math for that something like finding the difference between the cop car and the car's x, and y coordinates.
those two numbers give you two sides of a triangle then use
Math.tan (a) = xdistance/ydistacne
where a is the angle of the car so that it points in the right direction then set _rotation accordingly.
it looks pretty tuff i'm not even sure if that'l lwork
-
didnt work for me...mainly cuz i dont really understand the script...ill have to do this differently then...
-
Monkey Moderator
this function returns the angle between 2 coordinates...
The onEnterFrame function rotates a movieClip 'mc' so that it always points towards the mouse.
code:
function angle(ax,ay,bx,by) {
dx = ax - bx;
dy = ay - by;
deg = Math.atan2(dy,dx)*(180/Math.PI);
return deg += (deg >= 90 && deg < 180) ? -90 : 270;
}
mc.onEnterFrame = function(){
this._rotation = angle(this._x,this._y,_xmouse,_ymouse);
}
www.lexicon-design.co.uk
If we aren't supposed to eat animals, then why are they made of meat?
If Vegetarians like animals so much, why do they eat all their food?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|