Hello!
So I'm making a game about pollution. I have a superclass named dirt, and a list of subclasses to it.
I want to use the function isTouching to check if there is any object of the subclasses from dirt touching a trash can and if there is, I want to check what object it is and then remove it and add or decrease a counter score. That's what I'm trying to do in code:
something about this.
So I want to check if any object that is a waste is touching the trash can, if yes I want to check what type of object it is and based on that increased or decrease the counter, then remove. Help?
Edit: There is no object of type dirt in the World.
if (isTouching(dirt.class))
{
river world=(river)getWorld();
Actor x=this.getOneIntersectingObject(dirt.class);
if (x.equals(ziar.class)||x.equals(carton_cutie.class)){
world.getObjects(Counter.class).get(0).add(100);
}
else{
world.getObjects(Counter.class).get(0).add(-100);
}
world.removeObject(x);
}