|
Finding the angle of a movie clip
Wat's the difference between to find angles of two points which is
(x1,x2) and the other point be (_xmouse,_ymouse).
To find the angles we subtract from one point to the other
like
method 1:
target x = (_xmouse - mc._x)
target y= (_ymouse - mc._y)
method 2:
target x = (mc._x - _xmouse)
target y = (mc._y - ymouse)
wat's the difference between with this two methods
wen i implement with this target x and y values to Math.atan2(y,x)
i am getting different results
does this two have any major difference????
i get the error especially in this program--------->
_________________________________
var spring:Number = 0.1;
var friction:Number = 0.9;
var springLength:Number = 75;
var vx:Number = 0;
var vy:Number = 0;
onEnterFrame = function () {
var dx:Number = ball._x - _xmouse;
var dy:Number = ball._y - _ymouse;
var angle:Number = Math.atan2(dy, dx);
var targetX:Number = _xmouse + Math.cos(angle) * springLength;
var targetY:Number = _ymouse + Math.sin(angle) * springLength;
vx += (targetX - ball._x) * spring;
vy += (targetY - ball._y) * spring;
vx *= friction;
vy *= friction;
ball._x += vx;
ball._y += vy;
clear();
lineStyle(1, 0, 100);
moveTo(ball._x, ball._y);
lineTo(_xmouse, _ymouse);
};
|