I have created a ball to intersect with some objects on my interface when it bounces off the paddle (as in the breakout game) however when I compile by Actor I get an error message saying
cannot find symbol - variable goldEgg. what can I do?
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 deltaX; // delat is movement in the x direction private int deltaY; // delta is movement in the y direction private int count = 2; private boolean fixed = true; // ???? public Robot() { } /** * Act. Move the Robot if we're not fixed to paddle. */ public void act() { if (!fixed) { move(); makeSmoke(); checkOut(); checkEggs(); } } /** * 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) { ((SquareWorld) getWorld()).RobotIsOut(); 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 (goldEgg != null) { getWorld().removeObject(goldEgg); deltaY = -deltaY; } } 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; } }