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

2013/12/12

How to make a class the criteria for a method?

Affan Affan

2013/12/12

#
I have made a method:
  public void destroy()
    {
        getWorld().removeObject(actor);
    }
And I have created a variable:
Actor actor = getWorld().getObjects();
And I have a question: What do I put in the parentheses of getObjects to make it so that when I call this method, I can put in the name of a class? Thanks for all responses ~Affan
bourne bourne

2013/12/12

#
First, getObjects returns a List which cannot be assigned to the variable actor of type Actor. Second, are you wanting something like this? :
public void destroy(Class aClass)
{
    getWorld().removeObjects(getWorld().getObjects(aClass));
}
You need to login to post a reply.