Hello guys! When i press a buton on my screen, i want all the enemys to shot bullets, then, when the bullets are gone, spawn new enemy. But I can t figure out how to spawn them after the bullets are gone and not before. Here is my code so far (the coordonates are for a grid that i made for the map, don t mind them):If someone could help me with this problem, I would be very grateful.
if (Greenfoot.mouseClicked(this)) { for(int i=1;i<9;i+=2) for(int j=-3;j<=3;j+=2) if(!getWorld().getObjectsAt(376+j*37, 61+i*19, Inamicii.class).isEmpty()) getWorld().addObject(new proiectil(), 376+j*37, 85+i*19); for(int i=0;i<=8;i+=2) for(int j=-4;j<=4;j+=2) if(!getWorld().getObjectsAt(376+j*37, 61+i*19, Inamicii.class).isEmpty()) getWorld().addObject(new proiectil(), 376+j*37, 85+i*19); } if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Inamicii.class).size() < 24) { for(int k=1;k<=3;k++) { int i=Greenfoot.getRandomNumber(9); int j=0; if(i%2==0) { if(i==4) j=getRandomNumber(-2,2); else if(i==2||i==6) j=getRandomNumber(-1,1); else j=0; j=j*2; } else if(i==1||i==7) while(j==0) j=getRandomNumber(-1,1); else while(j%2==0) j=getRandomNumber(-3,3); if (getWorld().getObjectsAt(376+j*37, 60+i*19, Inamicii.class).isEmpty()) { if(getWorld().getObjectsAt(376+j*37, 60+(i+1)*19, Inamicii.class).isEmpty()) { getWorld().addObject(new Inamicii(), 376+j*37, 60+i*19); getWorld().addObject(new umbra(), 376+j*37, 80+i*19); } else getWorld().addObject(new Inamicii(), 374+j*37, 60+i*19); } else k--; } } }