I'm trying to use a string array so I can scroll through different classes instead of hard programming everything. I'm trying to do something like:
I get an error saying that I'm defining a string in the third parameter when I define the actor "object" instead of a class. Is there a way I can make it defined as a class?
Thank You.
String[] objects = {"Wall.class"}; int collisionAmount=0; public void wallCollision() { while (collisionAmount<objects.length){ //Down check for (int i=-getImage().getWidth()/2+2; i<getImage().getWidth()/2; i++){ Actor object = getOneObjectAtOffset(i, getImage().getHeight()/2,objects[collisionAmount]); if (object!=null&&ymove>0){ymove=0;} } //Up check for (int i=-getImage().getWidth()/2+2; i<getImage().getWidth()/2; i++){ Actor object = getOneObjectAtOffset(i, -getImage().getHeight()/2,objects[collisionAmount]); if (object!=null&&ymove<0){ymove=0;} } //Left check for (int i=-getImage().getHeight()/2; i<getImage().getHeight()/2; i++){ Actor object = getOneObjectAtOffset(-getImage().getWidth()/2, i,objects[collisionAmount]); if (object!=null&&xmove<0){xmove=0;} } //Right check for (int i=-getImage().getHeight()/2; i<getImage().getHeight()/2; i++){ Actor object = getOneObjectAtOffset(getImage().getWidth()/2, i,objects[collisionAmount]); if (object!=null&&xmove>0){xmove=0;} } collisionAmount++; } collisionAmount=0; }