This site requires JavaScript, please enable it in your browser!
Greenfoot back
MTelesca
MTelesca wrote ...

2019/2/18

help

MTelesca MTelesca

2019/2/18

#
How do I make it so when all of one actor(5 at start) are gone the game stops?
danpost danpost

2019/2/18

#
MTelesca wrote...
How do I make it so when all of one actor(5 at start) are gone the game stops?
In your MyWorld class, add an act method that gets a list of all that type object in the world and, if empty, stops the game.
MTelesca MTelesca

2019/2/19

#
danpost wrote...
MTelesca wrote...
How do I make it so when all of one actor(5 at start) are gone the game stops?
In your MyWorld class, add an act method that gets a list of all that type object in the world and, if empty, stops the game.
what would the code for the act method be?
danpost danpost

2019/2/19

#
MTelesca wrote...
what would the code for the act method be?
public void act()
{
    if (getObjects(Enemy.class).isEmpty()) // adjust class name as needed
    {
        Greenfoot.stop();
    }
}
MTelesca MTelesca

2019/2/20

#
This worked perfectly, thank you
You need to login to post a reply.