Hi,
when I press enter, I wanna load a new world in my game, if there is (or isn't) a certain object currently in my world.
How do i check if there is an object currently located in the world?
List objectslookingfor = getObjects(ObjectLookingFor.class); if (objectslookingfor.size() == 0) addObject(new ObjectLookingFor(), x, y);
import java.util.List;
String key = Greenfoot.getKey();
if (key != null)
{
if ("enter".equals(key))
{
getWorld().addObject(new Man(), x, y); // x and y can be literals or preset integer variables
// getWorld().removeObject(this); *** if removing object also ***
}
}private A theA;
public A getA()
{
return theA;
}public static int x =0;
public static int y =0;
public void act()
{
x=getX();
y=getY();
}public void addC()
{
Actor A;
A=getOneIntersectingObject(A.class);
if(A !=null)
{
World world;
world=getWorld();
world.addObject(new C(), getX(), getY());
}
}addObject(new C(), A.x, A.y);
if (intersectingB()) addC();'
private boolean intersectingB()
{
Actor b;
b = getOneIntersectingObject(B.class);
return (b != null)
}
private void addC()
{
World world;
world.getWorld();
world.addObject(new C(), getX(), getY());
} public void addC()
{
Actor A;
A=getOneIntersectingObject(A.class);
if(A !=null)
{
World world;
world=getWorld();
world.addObject(new C(), getX(), getY());
}
} addObject(new C(), A.x, A.y);
addObject(new C(), A.getX(), A.getY());
List cList = getIntersectingObjects(C.class);
if (cList.size() >= maxCperB)
{
getWorld().removeObjects(cList); // removing all c objects that are on this b object
getWorld().removeObject(this); // removing this b object
}