Hello, I am relatively new to this and I had a problem while programming. I want one of my actors "A" to eat another actor "B", which will result in the disappearance of a third actor "C" as well. How do I do this?
Thank you
//in the same method which eats actor b;
List<C> cObjects = getWorld().getObjects(C.class);
if (!cObject.isEmpty()) {
getWorld().removeObject(cObjects.get(0));
}//in the same method which eats actor b;
public void removeObjectC(int objectsNumber) {
List<C> cObjects = getWorld().getObjects(C.class);
if (!cObjects.isEmpty()) {
for (int i = 0; i < cObjects.size(); i++) {
if (cObjects.get(i).getNumber() == objectsNumber) {//get number has to be declared in class C and must return the value of the objects counter;
getWorld().removeObject(cObjects.get(i));
}
}
}
}getWorld().removeObjects(getWorld().getObjects(C.class));
public void removeObjectC(int objectsNumber) {
List<C> cObjects = getWorld().getObjects(C.class);
...
}for (Object obj : getObjects(ClassName.class))
{
ClassName classObj= (ClassName) obj;
classObj.classNameMethod();
}