Hi,
the issue that I am having is that when the object "RedTile" tries to remove the objects "Back" , "BlueTile" , "GreenTile" and "WhiteTile" it cannot find the variable "Back". The code is shown below:
Now, the object "Back" was not originally on the world but was added to the world by the "Brick" object. That code is shown below:
Any help would be greatly appreciated!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class RedTile here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class RedTile extends Actor
{
private Brick brick;
public RedTile(Brick pointBrick)
{
brick = pointBrick;
}
/**
* Act - do whatever the RedTile wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(Greenfoot.mouseClicked(this))
{
brick.setRed();
getWorld().removeObject(Back);
getWorld().removeObject(BlueTile);
getWorld().removeObject(GreenTile);
getWorld().removeObject(WhiteTile);
}
}
}getWorld().addObject(new Back(this), 300, 300);
getWorld().addObject(new RedTile(this), 208, 248);
getWorld().addObject(new BlueTile(this), 208, 335);
getWorld().addObject(new GreenTile(this), 394, 248);
getWorld().addObject(new WhiteTile(this), 394, 335);
