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

2013/1/9

testing for actors

bonana bonana

2013/1/9

#
I want my actor z to check wether actor a, actor b or actor c are currently in the world. If none of them is in the world actor z should call a method. Could you give some example code please?
Gevater_Tod4711 Gevater_Tod4711

2013/1/9

#
In your z class you need code like this:
if (getWorld().getObjects(a.class).isEmpty() && getWorld().getObjects(b.class).isEmpty() && getWorld().getObjects(c.class).isEmpty()) {
   //call the method;
}
bonana bonana

2013/1/9

#
Thank you for your quick answer! It works :-)
You need to login to post a reply.