I´m building my own Space Invaders in Java with Greenfoot and I have a Spaceship which shoots the Aliens, but the Bullets stop at the top of the map and stay there so I wrote this method which should remove a bullet if it hits the top of the but it doesn't work. What´s the problem?
public void disappearIfOnTop() {
Actor Bullet = getOneIntersectingObject(Actor.class);
getY();
if(getY() == 0) {
World world;
world = getWorld();
world.removeObject(Bullet);
}
}
Edit: they are getting removed if they hit another bullet which is stuck on the top.