I have powerups in my game (they increase the speed of the player). I have the following code to remove them after the first 10 seconds. However, I want the powerups to reappear in level 2. I have the following code in GameWorld2 (level 2) to put the powerups on the screen, but it won't work
I do have all the variables and other things defined elsewhere (like above i have public static int numPowerUps = 4; for example)
if (GameWorld1.PowerUpTimer.millisElapsed() > 10000)
{
getWorld().removeObject(this);
PowerUpTimer.mark();
}for (int x = 0; x < numPowerUps; x++)
{
xPos = Greenfoot.getRandomNumber(getWidth());
yPos = Greenfoot.getRandomNumber(getHeight());
addObject(new PowerUp(), xPos, yPos);
}
