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

2021/1/21

I need help

Yoyoyo Yoyoyo

2021/1/21

#
How do I gather all objects of a actor class in a variable?
danpost danpost

2021/1/22

#
Yoyoyo wrote...
How do I gather all objects of a actor class in a variable?
For what purpose? What are you going to do with the list? I suspect you will iterate through the list either to do something with all the actors or with specific types within the list, in which case:
for (Object obj : getObjects(Actor.class))
{
    Actor actor = (Actor) obj;
    //  perform stuff on "actor"
}
You need to login to post a reply.