Hey guys, I was wondering how would I go about removing all objects if something equals a null? Right now in my game I have an aligator chasing frogs and trying to kill the frogs. If the camel hits the frog than the camel changes the image to "Player 2 wins" and goes to the center of the screen. The only problem I'm having is I would like to remove all of the 30 or so frogs that are on the screen also. Please help?
Here is my code.
import greenfoot.*;
import java.util.List;
// (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Camel here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Camel extends Mover
{
/**
* Act - do whatever the Camel wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
checkForArrowKeys(6);
checkEdge();
Actor Camel=getOneIntersectingObject(Aligator.class);
if(Camel!=null)
{
getWorld().removeObject(Camel);
setImage(new GreenfootImage("Player2.jpg"));
setLocation(425, 275);
GreenfootImage img = getImage();
img.scale(850,550);
removeObjects(getObjects(Frog.class));
//List objects =getObjects(null);
//removeObjects(Frog);
//Greenfoot.stop();
}
}
public void checkForArrowKeys (int adjust)
{
if ( Greenfoot.isKeyDown("a") )
{
setLocation(getX() - adjust, getY());
}
if ( Greenfoot.isKeyDown("d") )
{
setLocation(getX() + adjust, getY() );
}
if ( Greenfoot.isKeyDown("w") )
{
setLocation(getX() , getY() - adjust );
}
if ( Greenfoot.isKeyDown("s") )
{
setLocation(getX() , getY() + adjust );
}
}
public void checkEdge()
{
int w=getWorld().getWidth();
int h=getWorld().getHeight();
setLocation((getX()+w)%w, ((getY()+h)%h));
}
}

