hi, i am having problems with my game that the enemy doesn't spawn in the multiplayer world. I have a wall in the middle to separate the starfighters but when my starfighter 1 shoots, none of them respawn, only for my starfighter 2. Can someone please help asap? here is the code for the fireball2...
import greenfoot.*;
public class Fireball2 extends Actor
{
private int direction = 270;
private int speed = 7;
private Starfighter3 starfighter3;
public Fireball2 (Starfighter3 ship)
{
starfighter3 = ship;
setRotation(direction);
}
public void act()
{
move(speed);
checkSpeedPU();
if (getWorld() == null) return;
disappear();
}
private void checkSpeedPU()
{
Powerup pu = (Powerup)getOneIntersectingObject(Powerup.class);
if (pu == null) return;
if (pu.getType() == Powerup.SPEED_PU)
{
starfighter3.getSpeedBoost();
getWorld().removeObject(pu);
getWorld().removeObject(this);
}
}
public void disappear()
{
Actor BugEnemy;
BugEnemy = getOneObjectAtOffset(0, 0, BugEnemy.class);
Actor InsectEnemy;
InsectEnemy = getOneObjectAtOffset(0, 0, InsectEnemy.class);
Actor Bee;
Bee = getOneObjectAtOffset(0, 0, Bee.class);
Actor DarkPower;
DarkPower = getOneObjectAtOffset(0, 0, DarkPower.class);
if (BugEnemy != null)
{
World world;
world = getWorld();
world.removeObject(BugEnemy);
MyGame2 mygame2 = (MyGame2)world;
Counter counter = mygame2.getCounter();
counter.addScore();
int halfWorldWidth = world.getWidth()/2;
int x = Greenfoot.getRandomNumber(halfWorldWidth);
if (getX() >= halfWorldWidth) x += halfWorldWidth;
BugEnemy.setLocation(x, Greenfoot.getRandomNumber(world.getHeight()));
world.removeObject(this);
return;
}
if (InsectEnemy != null)
{
World world;
world = getWorld();
world.removeObject(InsectEnemy);
MyGame2 mygame2 = (MyGame2)world;
Counter counter = mygame2.getCounter();
counter.addScore();
int halfWorldWidth = world.getWidth()/2;
int x = Greenfoot.getRandomNumber(halfWorldWidth);
if (getX() >= halfWorldWidth) x += halfWorldWidth;
InsectEnemy.setLocation(x, Greenfoot.getRandomNumber(world.getHeight()));
world.removeObject(this);
return;
}
if (Bee != null)
{
World world;
world = getWorld();
world.removeObject(Bee);
MyGame2 mygame2 = (MyGame2)world;
Counter counter = mygame2.getCounter();
counter.addScore();
int halfWorldWidth = world.getWidth()/2;
int x = Greenfoot.getRandomNumber(halfWorldWidth);
if (getX() >= halfWorldWidth) x += halfWorldWidth;
Bee.setLocation(x, Greenfoot.getRandomNumber(world.getHeight()));
world.removeObject(this);
return;
}
if (DarkPower != null)
{
World world;
world = getWorld();
world.removeObject(DarkPower);
world.removeObject(this);
return;
} else {
if (getY()<=0)
{
getWorld().removeObject(this);
return;
}
}
}
}