actually everything worked like a charm!!!
my new layout
public class dolphin extends Actor
{
private int counter = 0;
/**
* Act - do whatever the dolphin wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
move(20);
if (isAtEdge())
{
turn(135+Greenfoot.getRandomNumber(90));
counter++; //increments everytime dolphin hits edge
disappear();
}
}
/**
* keep count of how many times object has hit edge.
* if counter accumelates to == 5 remove object.
*/
public void disappear()
{
if (counter == 8)
{
getWorld().removeObject(this); //makes object vanish
}
}
public dolphin()
{
turn(Greenfoot.getRandomNumber(360));
}
}

