I am trying to make a object move in right for 15 seconds than to the left for 15 seconds when it is touching another object.when i try it the object just only moves back a forth.
public void Pipetouch()
{
if (isTouching(Upipie.class)){
{
setLocation(getX(), getY()+3);
}
}
if (isTouching(Spipe.class)){
setLocation(getX()+3, getY());
Greenfoot.delay(5);
setLocation(getX()-3, getY());
Greenfoot.delay(5);
}
}

