How can I delay just one object (not the entire program with Greenfoot.delay())? I have a parent class and then four subclasses that will all use this delay method at some point.
public void act() {
if (delay) return; // if some delay boolean is true, exit method
...
}// field
int delayTimer;
// act method
public void act()
{
if (delay > 0 && --delay > 0) return; // do nothing if delaying
//
if (<< some condition >>)
{
delay = 180; // initiate delay
// other actions
}
//
}if (delay > 0)
{
if (--delay == 0) getWorld().removeObject(this);
return;
}public void removeDelay()
{
int delayTime = 1000;
while(delayTime > 0) delayTime--;
if(delayTime == 0) getWorld().removeObject(this);
}public void removeDelay()
{
int delayTime = 1000;
while(delayTime > 0) delayTime--;
if(delayTime == 0) getWorld().removeObject(this);
}public void removeDelay()
{
getWorld().removeObject(this);
}