Hi, I am trying to make a small movieclip that rotate itself based on the mouse coordinates while pressed. But the problem is, using the Math.sin function, when I pass the result to angle it won´t go to far than 50 degrees where it should be 90. What´s the matter?
My code
on(press){
isActing = True;
}
onClipEvent(enterFrame){
if (isActing == True){
//This is to get the real coordinates based on the movieclip position
tx = _root._xmouse - this._x;
ty = - (_root.ymouse - this._y); // y is inverted in flash
hyp = Math.sqrt(tx*tx + ty*ty);
sin = Math.sin(ty/hyp);
angle = 180 * sin / Math.PI;
}
}
I was planing to get a base angle and the current mouse angle and then subtract they by rotating the movieclip. But so I´ve got the angle problem. How do I fix it??
Tkz Senocular, but this function has a problem: if i start to press on the top of my movieclip it will follow the mouse to de rigth and left very wel. But, if press in the same place and move the mouse in a circle going down, after passing the center of the image the rotation invert and start to move in the opposite way, insted of keep moving. How I can handle this problem???
If I understand what you’re saying, you just need to include an offset. When you click the movieclip, find the angle to the mouse at that point of time and base all further movement off that angle. In other words, add it to the equation above.