what makes this platform know when to turn
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
public class Platform extends Actor
{
private int speed = 4;
private int leftTurn = 270;
private int rightTurn = 480;
public void act()
{
setLocation ( getX() + speed, getY() );
Actor actor = getOneIntersectingObject(null);
if(actor != null) {
actor.setLocation ( actor.getX() + speed, actor.getY() );
}
if (atTurningPoint()) {
speed = -speed;
}
}
public boolean atTurningPoint()
{
return (getX() <= leftTurn || getX() >= rightTurn);
}
}