Since updating a new method in world my scenario is really slow.
While running the game the world have to add Object in a delay to the world. Not only the actors lag, the scenario lags because my counting var counts slow...
Someone an idea for help?
If you need the scenario code and not only the world code, ask me for
Below the world code
import greenfoot.*;
public class Spiel extends World
{
Raumschiff raumschiff;
GreenfootSound backgroundSound = new GreenfootSound("Fly.mp3");
private int ad=0;
private int ay;
private int at=0;
public Spiel()
{
super(900, 900, 1);
backgroundSound.playLoop();
GreenfootImage bg = new GreenfootImage("bgspiel.png");
raumschiff=new Raumschiff();
this.addObject(raumschiff, 450, 450);
}
public void act()
{
Gegnerspawnen();
}
public void Gegnerspawnen()
{
ay=Greenfoot.getRandomNumber(4);
Enemy enemy=new Enemy(1);
Tank tank=new Tank();
if(ad==40){
if(ay==0){
this.addObject(enemy, Greenfoot.getRandomNumber(900), 0);
ad=0;
}
if(ay==1){
this.addObject(enemy, Greenfoot.getRandomNumber(900), 900);
ad=0;
}
if(ay==2){
this.addObject(enemy, 0, Greenfoot.getRandomNumber(900));
ad=0;
}
if(ay==3){
this.addObject(enemy, 900, Greenfoot.getRandomNumber(900));
ad=0;
}
}
if(at==200)
{
if(ay==0){
this.addObject(tank, Greenfoot.getRandomNumber(900), 0);
at=0;
}
if(ay==1){
this.addObject(tank, Greenfoot.getRandomNumber(900), 900);
at=0;
}
if(ay==2){
this.addObject(tank, 0, Greenfoot.getRandomNumber(900));
at=0;
}
if(ay==3){
this.addObject(tank, 900, Greenfoot.getRandomNumber(900));
at=0;
}
}
ad++;
at++;
}
}

