I'm trying to make a game where you can shoot enemies and get to the next Level, through a door which is being added once every Enemy is dead.
My problem is that the getObjects doesn't work and I'm not sure why.
I even asked my teacher in school but she didn't have an answer to my problem.
I've tried
and
Both didn't work..
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
public class LevelOne extends World
{
/** Constructor for objects of class MyWorld.*/
public LevelOne()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
populateLevelOne();
}
public void populateLevelOne()
{
addObject(new Player(), 50, 200);
addObject(new Enemy(), 400, 300);
}
public void detectEnemy()
{
showText("detectEnemy", 100, 150); //conformed method works
if (getObjects(Enemy.class).isEmpty())
{
showText("Added door", 100, 200); //confirm door added
addObject(new Door(), 500, 200);
}
}
}
if (getObjects(Enemy.class).isEmpty())
if (getObjects(Enemy.class).size() == 0)

