okay im making a game where when you click a line is drawn in the direction you clicked. I need to use hitTest with it, how would i go about doin that? here is the stuff
This is on the main timeline, it links to the gun. “bullet” is an empty clip
gun.onEnterFrame = function ()
{
var angle:Number = Math.atan2 (_root._ymouse - this._y, _root._xmouse - this._x);
this._rotation = angle * 180 / Math.PI;
if(isMouseDown){
if(_root.canfire == true){
mc = _root.attachMovie ("bullet", "bullet" + _root.getNextHighestDepth (),
_root.getNextHighestDepth ());
mc._x = this._x + Math.cos (angle) * (this.w - 0);
mc._y = this._y + Math.sin (angle) * (this.w - 0);
var maxWaver:Number = 1;
var waver:Number = (Math.random () * maxWaver * 2 - maxWaver) * Math.PI / 180;
mc.angle = angle + waver;
_root.canfire = false
_root.reloader.reload.gotoAndPlay(2);
}
}
}
_root.onMouseDown = function ()
{
isMouseDown = true;
};
_root.onMouseUp = function ()
{
isMouseDown = false;
};
Now here is the code on the first frame of the bullet clip
decay = 15;
this.onEnterFrame = function()
{
if(this.angle != undefined)
{
this.disp = _root.createEmptyMovieClip(this._name+_root.getNextHighestDepth(), _root.getNextHighestDepth());
this.disp.lineStyle(3, 0xFF0000);
this.disp.moveTo(this._x, this._y);
this.disp.lineTo(this._x + Math.cos(this.angle)*800, this._y+Math.sin(this.angle)*800);
delete this.angle;
}
if(this.disp != undefined)
{
this.disp._alpha -= decay;
if(this.disp._alpha <= 30)
{
this.disp.removeMovieClip();
this.removeMovieClip();
delete this.onEnterFrame;
}
}
}
i Need to hitTest the line drawn in ^ with a clip called enemy. How would i go about doing that?