Shooting Bullets at the Mouse

Hi everyone.
I need to make a bullet that will shoot in the direction of the mouse.
So far I have pretty much everything else.
Can someone explain what I should do?
Ill post the swf and fla, right now the bullet doesnt move, targets are “respwaned” on release at the momment.

[URL=“http://www.filefactory.com/get/v3/h.php?f=369e5bbfabddfb86fc83b06c&b=3&c=a4c3f6cd326a6fdb”]http://www.savefile.com/files.php?fid=8847094

:sc:

Thanks Canadian but i cant open it… i have flash MX

var depth = 0;
onMouseDown = function () {
 var b = this.attachMovie("bullet", "bullet" + depth, depth++);
 b._x = Stage.width / 2, b._y = Stage.height / 2;
 b._t = Math.atan2(this._ymouse - b._y, this._xmouse - b._x);
 b.onEnterFrame = function() {
  this._x += Math.cos(this._t) * 3;
  this._y += Math.sin(this._t) * 3;
 };
};

You’ll need a movie clip in the library with the the linkage id* bullet*.

or a shorter method:


var depth = 0;
onMouseDown = function () {
 var b = this.attachMovie("bullet", "bullet" + depth, depth++, {_x:Stage.width / 2, _y:Stage.height / 2, _t:Math.atan2(this._ymouse - b._y, this._xmouse - b._x), onEnterFrame:function() {
  this._x += Math.cos(this._t) * 3;
  this._y += Math.sin(this._t) * 3;
 };});
};

thanks guys but that wont work, or i dont know how to

i need the bullet to be generated from the point of the gun (see swf) and i need it to move with the character (i attached a new swf with a moveable char. w,a & d to move)

i bet theres an easy way to do this, just not sure how

Err, that’s exactly the same . . .

bump i think you posted right after me canadian

Lol, Yeah it’s the same… but shorter.