I believe I copied all the lines from your game to mine and I get and error message for this(0); saying "call to this must first be a statement in constructor."
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Platform here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Platform extends Actor
{
int speed;
public void Platform()
{
this(0);
}
public Platform(int rate)
{
speed=rate;
}
public void act()
{
if (speed == 0) return;
int worldWidth = getWorld().getWidth();
setLocation(getX(),getY()-1);
Actor Player=getOneIntersectingObject(Player.class);
setLocation(getX()+speed,getY());
int dx =(int)Math.signum(speed);
int dist = speed;
Actor obstacle = getOneIntersectingObject(null);
while (obstacle != null)
{
setLocation(getX()-dx, getY());
dist -= dx;
obstacle = getOneIntersectingObject(null);
}
if(Player != null)Player.setLocation(Player.getX()+dist, Player.getY());
if((speed > 0 &&getX() >= worldWidth-50)||(speed < 0 && getX() <= 50))speed =-speed;
}
}
