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

2013/5/25

Find out if one Actor no longer exists in the world

carhad carhad

2013/5/25

#
I need to know if one TYPE of Actor exists in the world. If it does, the game should continue, if not it should start the next level.
bourne bourne

2013/5/25

#
Use the World's method getObjects(Class) Example:
if (!getObjects(MyActorType.class).isEmpty())
{
    // Continue
}
else
{
    // Next level
}
carhad carhad

2013/5/25

#
Okay level 2 seems to be the same as level 1?
carhad carhad

2013/5/25

#
I put the code in the level one class.
carhad carhad

2013/5/25

#
Help?
danpost danpost

2013/5/25

#
In the Level1 class, use:
if (getObjects(MyActorType.class).isEmpty()) Greenfoot.setWorld(new Level2());
carhad carhad

2013/5/25

#
By the way I am very new to Greenfoot but not so much as to java itself.
danpost danpost

2013/5/25

#
If you are somewhat familiar with Java, then all you should need to review is the Greenfoot documentation and tutorials. Just quickly scan over what methods are available in each of the classes and follow the tutorials. If you wish to improve your Java knowledge, check out the Java tutorials. There is an abundance of information included in its trails.
carhad carhad

2013/5/25

#
So I did that and It showed level2 at the start. Oh in the scenario there are more then one of the same actor in the world. And I also have to go now so.........Bye! For now.
You need to login to post a reply.