Hamly
12-04-2007, 05:45 PM
I have a button that will set an Interval to use a function that attachs a MC
that works fine, and so does the function. I also have it so every 5 seconds a MC will be attached for the "enemy" now I want it so lets say the one I attach and the enemies hit they will be removed. this is the code for attaching them
the one when I press the button:
function spawntank01(){
var t = attachMovie("Tank_01","tank01_"+_root.getNextHighestDepth(), getNextHighestDepth(),{_x:0,_y:435});
t.onEnterFrame = checkTankHit;
clearInterval(spawntanks01);
}
function checkTankHit(){
if(_root.wall.hitTest(this)){
wall.swapDepths(0);
wall.removeMovieClip();
}
}
and the enemies:
function spawnenemytank(){
var e = attachMovie("enetank","enetank_"+_root.getNextHighestDepth(),getNextHighestDepth() ,{_x:650,_y:435});
e.onEnterFrame = entankhit;
}
function entankhit(){
if(["tank01_"+_root.getNextHighestDepth()].hitTest(this)){
this.swapDepths(0);
this.removeMovieClip();
}
}
setInterval(spawnenemytank,5000);
If you would like more info or anything I'll give ya it, thanks.
that works fine, and so does the function. I also have it so every 5 seconds a MC will be attached for the "enemy" now I want it so lets say the one I attach and the enemies hit they will be removed. this is the code for attaching them
the one when I press the button:
function spawntank01(){
var t = attachMovie("Tank_01","tank01_"+_root.getNextHighestDepth(), getNextHighestDepth(),{_x:0,_y:435});
t.onEnterFrame = checkTankHit;
clearInterval(spawntanks01);
}
function checkTankHit(){
if(_root.wall.hitTest(this)){
wall.swapDepths(0);
wall.removeMovieClip();
}
}
and the enemies:
function spawnenemytank(){
var e = attachMovie("enetank","enetank_"+_root.getNextHighestDepth(),getNextHighestDepth() ,{_x:650,_y:435});
e.onEnterFrame = entankhit;
}
function entankhit(){
if(["tank01_"+_root.getNextHighestDepth()].hitTest(this)){
this.swapDepths(0);
this.removeMovieClip();
}
}
setInterval(spawnenemytank,5000);
If you would like more info or anything I'll give ya it, thanks.