Hello. I am working on a school project and all I want to is have an actor remove itself and another actor already in the world. To have the actor remove itself I just used getWorld().removeObject(this); and for the other actor I used getWorld().removeObject(orderSlip2);. But when I run my code and click the OrderSlip1 actor, it removes neither object. I'm really just trying to make a simple mouse pressing game that adds and removes objects. Everything else I've tried to do in Greenfoot has either been too ambitious or I'm not using the API correctly. It's super frustrating.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class OrderSlip1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class OrderSlip1 extends Actor
{
public OrderSlip2 orderSlip2;
/**
* Act - do whatever the OrderSlip1 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
orderSlip2 = new OrderSlip2();
if (Greenfoot.mousePressed(this) == true) {
getWorld().removeObject(this);
getWorld().removeObject(orderSlip2);
}
}
}

