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

2012/3/18

How can i check whether an actor is in the world?

IsaacIIV IsaacIIV

2012/3/18

#
This is probably an easy question but i have no idea how to check whether an actor is in the world or not?
danpost danpost

2012/3/18

#
If there is only one of its class in the world, then from the world:
if (!getObjects(SubActorClassName.class).isEmpty())
and from another actor:
if(!getWorld().getObjects(SubActorClassName.class).isEmpty())
If you already have a reference to the actor (actorName), then
if (actorName.getWorld() != null)
IsaacIIV IsaacIIV

2012/3/18

#
Thank-you, working great :)
You need to login to post a reply.