Hi, I know I already had this discussion posted but I didn't get anything out of it. However I changed the way it was. But now there is a new problem....
Okay here is everything in detail:
So I have got an Boss Enemy and I am telling him to spawn when the time is right but he won't spawn, if I then insert a Boss Enemy manually the Boss Enemy that was supposed to spawn spawns but then like 5 seconds later another one spawns and then another one and so on....
Here is the coding:
Can u guys find the bug and tell me how to fix it, cuz I can't!
int BossSpawn = 1;
int Counter = 3;
private int direction = 1;
/**
* Act - do whatever the BossEnemy wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (canSee(Bullet.class))
{
eat(Bullet.class);
Counter--;
}
if (Counter == 0)
{
getWorld().removeObject(this);
}
if ((direction < 0 && getX() < 20) || (direction > 0 && getX() > getWorld().getWidth()-20))
{
direction = -direction;
}
if (BossSpawn==50)
{
removeObject(EnemyRocket.class);
getWorld().addObject(new BossEnemy(), 400, 50);
}
setLocation(getX()+5*direction, getY());
BossSpawn++;
}
}