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

2018/3/8

Removing object

ZiweZhang ZiweZhang

2018/3/8

#
I have this code for removing an object but it only removes the object it's touching. I want to remove all object from the same class at once when an object touches another. Can someone help me?
public void removeObject(Class clss)
    {
        Actor actor = getOneObjectAtOffset(0, 0, clss);
        if(actor != null) {
            getWorld().removeObject(actor);
        }
    }
Super_Hippo Super_Hippo

2018/3/8

#
This should work:
getWorld().removeObjects(getWorld().getObjects(clss));
You need to login to post a reply.