Hello,
I made an actor called "mothership", it's something like a boss enemy. It constantly moves to the left till it touches the left edge then i remove it with
But since i added this code to my world class, it just gets moved to the right egde again and i don't know why:
Maybe you can find the error.
Thanks :)
if (getX() <= 1)
{
canShoot = false;
getWorld().removeObject(this);
}private boolean MSSpawned = false;
int alertTimer = 3*60;
int MSSoundTime = 20*60;
GreenfootSound MothershipSound = new GreenfootSound("Mothership.mp3");
GreenfootSound MothershipAlarm = new GreenfootSound("MothershipAlarm.mp3");private void addMothership()
{
if (!MSSpawned && Greenfoot.getRandomNumber(2500) == 1)
{
MSSpawned = true;
MothershipAlarm.play();
addObject(msalert, 470, 300);
}
if (MSSpawned)
{
alertTimer--;
}
if (alertTimer <= 0)
{
removeObject(msalert);
MothershipAlarm.stop();
addObject(mothership, 895, 450);
MothershipSound.play();
}
if (MSSpawned && alertTimer <= 0)
{
MSSoundTime--;
}
if (MSSoundTime <= 0)
{
MothershipSound.stop();
}
}
