As the title says I need a code to wait for 10 seconds then proceed to the next code, my case is here, the code happens when ammunition turns to 0 then a text displays "not enough ammo" I would like that text to be displayed in 2 seconds then be removed immediately.I temporarily used the loop of adding 1 to the variable until 10 then proceeds but then it doesn't work.Please help.
if ("z".equals(Greenfoot.getKey())){
if(meh.ammo != 0)
{
shot2 b = new shot2();
getWorld().addObject(b, getX()+10, getY()+10);
meh.ammo --;
}
else if (meh.ammo == 0 && meh.notenammo != 10 )
{
getWorld().addObject(new NA(), getX(), getY());
meh.notenammo ++;
if (meh.notenammo == 10){
getWorld().removeObjects(getWorld().getObjects(NA.class));
}
}
}

