Would you like to react to this message? Create an account in a few clicks or log in to continue.

Actionscript [MC always faces the mouse]

Go down

Actionscript [MC always faces the mouse] Empty Actionscript [MC always faces the mouse]

Post by Wingedge Thu Oct 16, 2008 7:46 pm

This formula will rotate your movieclip to where your mouse is positioned

// getting the radian
myRadians = Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x);
// converting radian to degrees
myDegrees = Math.round((myRadians*180/Math.PI));
// add a rotation depending on where your MC is facing by default
this._rotation = myDegrees+180;

//this formula moves the MC towards the mouse
//

this._x += Math.sin (this._rotation * Math.PI / 180) * (2);
this._y += Math.cos (this._rotation * Math.PI / 180) * -(2);
Wingedge
Wingedge
Admin
Admin

Male
Number of posts : 77
Age : 40
Name : Sir Francis
Year Level : Instructor
Location : UC
Registration date : 2008-06-10

Credits
GP: 9999

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum