Actionscript [MC always faces the mouse]
:: Lessons :: Advance Lessons
Page 1 of 1
Actionscript [MC always faces the mouse]
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);
// 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- Admin
-
Number of posts : 77
Age : 40
Name : Sir Francis
Year Level : Instructor
Location : UC
Registration date : 2008-06-10
Credits
GP: 9999
Similar topics
» Actionscript [MC follows mouse and hiding mouse cursor]
» Actionscript [Variable Declaration]
» Actionscript [Firing Projectiles]
» Actionscript [Collision of 2 Movie Clips]
» Actionscript [Moving Movie Clips using Keyboard]
» Actionscript [Variable Declaration]
» Actionscript [Firing Projectiles]
» Actionscript [Collision of 2 Movie Clips]
» Actionscript [Moving Movie Clips using Keyboard]
:: Lessons :: Advance Lessons
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|