How do I move from Level 1 (Square World) to Level 2 (Circle World) when I have completed the level. I have tried different plans but I keep getting the error: cannot find symbol - constructor SquareWorld(Robot). can anyone help?
Here is my code for my main character (Robot) as it moves from world to world
import java.util.List;
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* The Robot of the game. It moves and bounces off the walls and the paddle.
*
* @author
* @version (Version 1.0)
*/
public class Robot extends Actor
{
private int points = 0;
private Counter counter;
private HealthBar healthBar;
private int deltaX; // delat is movement in the x direction
private int deltaY; // delta is movement in the y direction
private int count = 2;
//private int CircleWorld;
//private int SquareWorld;
//private SquareWorld squareWorld;
private int level;
private boolean fixed = true; // ????
public Robot(Counter c, HealthBar hb)
{
counter = c;
healthBar = hb;
}
public Robot()
{
level = 1;
}
/**
* Act. Move the Robot if we're not fixed to paddle.
*/
public void act()
{
if (!fixed)
{
move();
makeSmoke();
checkEggs();
checkOut();
checkNextLevel();
}
}
/**
* Move the Robot. Thencheck what we've hit.
*/
public void move()
{
setLocation (getX() + deltaX, getY() + deltaY);
checkPaddle();
checkWalls();
}
/**
* Check whether we've hit one of the three walls. Reverse direction
*/
private void checkWalls()
{
if (getX() == 0 || getX() == getWorld().getWidth()-1) {
deltaX = -deltaX;
}
if (getY() == 0) {
deltaY = -deltaY;
}
}
/**
* Check whether we're out (bottom of screen).
*/
private void checkOut()
{
if (getY() == getWorld().getHeight()-1)
{
List<Paddle> paddles = getWorld().getObjects(Paddle.class);
Robot newRobot = new Robot(counter, healthBar);
getWorld().addObject(newRobot, paddles.get(0).getX(), paddles.get(0).getY() - 35);
paddles.get(0).setNewRobot(newRobot);
getWorld().removeObject(this);
}
}
/**
* Check whether we have hit an egg, and make the egg disappear if we have
*/
private void checkEggs()
{
Actor egg = getOneIntersectingObject(goldEgg.class);
if (egg != null)
{
getWorld().removeObject(egg);
deltaY = -deltaY;
counter.add(5);
}
egg = getOneIntersectingObject(yellowEgg.class);
if (egg != null)
{
getWorld().removeObject(egg);
deltaY = -deltaY;
counter.add(3);
}
egg = getOneIntersectingObject(redEgg.class);
if (egg != null)
{
getWorld().removeObject(egg);
deltaY = -deltaY;
counter.add(1);
}
egg = getOneIntersectingObject(blueEgg.class);
if (egg != null)
{
getWorld().removeObject(egg);
deltaY = -deltaY;
healthBar.add(-10);
}
//if (counter.getValue() >= 60) {
// gameOver();
}
private void checkPaddle()
{
Actor paddle = getOneIntersectingObject(Paddle.class);
if (paddle != null) {
deltaY = -deltaY;
int offset = getX() - paddle.getX();
deltaX = deltaX + (offset/10);
if (deltaX> 7) {
deltaX = 7;
}
if (deltaX < -7) {
deltaX = -7;
}
//SquareWorld mySquareWorld = (SquareWorld) getWorld();
//mySquareWorld.score();
}
}
/**
* Move the Robot a given distance sideways
*/
public void move(int dist)
{
setLocation (getX() + dist, getY());
}
/**
* Put out a puff of smoke (only on every second call).
*/
private void makeSmoke()
{
count--;
if (count == 0) {
getWorld().addObject ( new Smoke(), getX(), getY());
count = 2;
}
}
/**
* Release the Robot from the paddle.
*/
public void release()
{
deltaX = Greenfoot.getRandomNumber(11) - 5;
deltaY = -5;
fixed = false;
}
/**
* Check whether we should go to the next level, and if yes, start the next level.
*/
private void checkNextLevel()
{
if (getX() == getWorld().getWidth()-1) {
if (level == 1) {
level = 2;
getWorld().removeObject(this);
Greenfoot.setWorld(new SquareWorld(this));
}
else {
level = 1;
getWorld().removeObject(this);
Greenfoot.setWorld(new CircleWorld(this));
}
}
}
}

