is it possible to create a variable that contains all worlds and if so how?
public void hitGegnerBullet()
{
Actor GegnerBullet = getOneIntersectingObject(GegnerBullet.class);
if(GegnerBullet != null)
{
World myWorld2= getWorld();
Level1 level1 = (Level1)myWorld2;
HealthBar healthbar =level1.getHealthBar();
if(hitGegnerBullet == false)
{
healthbar.loseHealth();
hitGegnerBullet = true;
if(healthbar.health <=0)
{
leben = 0;
}
} else {
hitGegnerBullet = false;
}
}
}int gegnersSpawned;
int maxGegners = 10; // adjust as needed
public void addGegner()
{
if (gegnersSpawned < maxGegners)
{
addObject(new Gegner(), 100, 100); // wherever
gegnersSpawned++;
}
}
public void checkEndWave()
{
if (gegnersSpawned == maxGegners && getObjects(Gegner.class).isEmpty())
{
// end wave
}
}