my ship game have multishoot to multi targets,
but some shoots don’t hit targets
function ship_generator(num_ships){
//timespawn=720/num_ships*20;
timespawn=3000;
trace("TimeSpawn :"+timespawn);
setInterval(spawn_ship,timespawn);
}
function spawn_ship(){
//if(j==null){j=-1;}
j =(j==null)? -1 : j;
j++;
rand_ship_type=random(3);
_root.b_ship++;
//trace("rand"+rand_ship_type);
switch (rand_ship_type){
case 0 :
ship_type="bship";
break;
case 1 :
ship_type="fighter";
// trace("you pressed 1");
break;
case 2 :
ship_type="bomber";
// trace("you pressed B");
break;
}
//var ShipHolder: = new myship();
trace("Ship :"+j+" TYPE:"+ship_type);
deep=j+16000;
attachMovie("mc_"+ship_type,"ship"+j,deep);
//attachMovie("mc_fighter","ship"+j,deep);
ship=_root["ship"+j];
ship._x=550;
ship._y=250;//Math.random()*200;
ship.velx=-Math.random()*8+2;
ship.vely=0;//Math.random()*4;
ship.onEnterFrame = function() {
this._x+=this.velx;
//this._y+=this.vely+Math.random()*2;
_root.acerta(this);
_root.onScreenShip(this);
}
}
_root.acerta is the function that test de hittest
function acerta(objecto){
//trace(" FUK acerta "+objecto+" ");
if(objecto.hitTest(_root.my_ship)==true){
trace(objecto+" Hit MySHIP");
}
upper_bullet=_root.n_bullet+_global.max_Bullet;
//trace(_root.n_bullet+"/"+upper_bullet);
for(i=_root.n_bullet;i<upper_bullet;i++){
bullet_ito=eval("_root.bullet"+i);
if(objecto.hitTest(bullet_ito)==true){
//trace(objecto+" HITED By bullet"+i);
removeMovieClip(objecto);
removeMovieClip(bullet_ito);
_root.n_shipDestroi++;
_root.n_INbullet--;
_root.n_ship--;
}
}
}
I cannot figure what’s wrong , i am gessing that when I fire more bullets the 1st miss target…
please check this for me
There’s any way I can do a better script… I mean the instead of the for go max bullets ( 16 ) it will just go on those that are on stage?
thaks