The web site for Flash ActionScript 3.0 game developers

 
         
   

HitTest

I'm trying to buid a simple shooting game.
I did some coding to attach obects with different names in a 2 sec interval regularly. also able to create bullects in the same manner(in a click).

But i'm unalbe to detect hitTest with a bullet and the object becouse names of the object and bullets changes.

The code is as follows..
///////////////////

depth = 1;
setInterval(runobj,2000);

function runobj() {
_root.depth++;
name = "obj"+depth;
_root.attachMovie("obj",name,depth);
var n:Number = randRange(100, 200);
_root[name]._x = n;
_root[name].onEnterFrame = function() {
updateAfterEvent();
this._y += 1;
};
}

function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}

_root.onMouseDown = function() {
depth++
name = "box"+depth;
_root.cir.attachMovie("box",name,depth);
_root.cir[name]._y = _root._ymouse;

_root.cir[name].onEnterFrame = function() {
updateAfterEvent();
this._x += 10;

};
};

//////////////

How can I do such a thing.
I hope you can help me! :roll:

thanks



Copyright Gary Rosenzweig