Search Tutorials
This tutorial is for you if you know basic, basic, basic actionscript. Pretty much all you have to do is copy and paste and maybe edit some names or numbers. Also you should already have a mouse cursor and a gun drawn, as this tutorial isn't for drawing, it's for a hard problem solved in an easy way. Just add this into the code for your gun:
onClipEvent(enterFrame){
this._x=_root.aimer._x/2+350
this._y=_root.aimer._y/5+300
dx= mx-this._x;
dy= my-this._y;
if (dx<0){
nom=-1*dx
} else {
nom=dx
}
if (dy<0){
nom + (-1*dy)
} else {
nom+dy
}
dir=90*(dy/nom)+45
this._rotation=dir;
}
This is Guaranteed to work just fine... if you read below. Important! This is ripped straight from my code...So "aimer" is just the name of the mouse cursor in my document. Change it to whatever your mouse cursor is. So if your mouse cursor was named "mouse" it would be this: this._x=_root.mouse._x/2+350 this._y=_root.mouse._y/5+300 And also this is true for the variables "mx" and "my." They are my mouse coordinates. Be sure to make any changes you have to to make this work. Good Luck!
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|