Good Day!
I Need help with a Libgdx Project. What i want is to remove a tile, which is in my graphics layer (layer 0).
This is what i got so far:
if(object1.getUserData() != null && object1.getUserData() == "polyblock"){
       polyblock1 = true;
       System.out.println("PLAYER 1");
}else if(object1.getUserData() != null && object1.getUserData() == "redcoin" || object1.getUserData() == "greencoin" ||  object1.getUserData() == "bluecoin" ){
           B2dObjectGetter.getCell(object1.getUserData() == "redcoin" ? 3 : object1.getUserData() == "greencoin" ? 4: 5).setTile(null);
      }
The coin bodies and the getCells Method:
for (int i = 3; i <= 5; i++){
     for (MapObject obj : map.getLayers().get(i).getObjects().getByType(EllipseMapObject.class)) {
            Ellipse ellipse = ((EllipseMapObject) obj).getEllipse();
            bdef.type = BodyDef.BodyType.StaticBody;
            bdef.position.set((ellipse.x + ellipse.width / 2) / GameJLibGDX.PPM, (ellipse.y + ellipse.height / 2) / GameJLibGDX.PPM);
            CircleShape shape = new CircleShape();
            coinbodies[i] = world.createBody(bdef);
            shape.setRadius(ellipse.width / 2 / GameJLibGDX.PPM);
            fixdef.shape = shape;
            coinbodies[i].createFixture(fixdef).setUserData(i == 3 ? "redcoin" : i == 4 ? "greencoin" : "bluecoin");
        }
    }
}
public static TiledMapTileLayer.Cell getCell(int i){
    TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0);
    System.out.println(coinbodies[i].getFixtureList());
    return layer.getCell((int)(coinbodies[i].getPosition().x * GameJLibGDX.PPM / 128),(int)(coinbodies[i].getPosition().y*GameJLibGDX.PPM / 128));
}
It seems to work really fine except one Thing:
Blue coin got hit:
The tiles of the other two coins move instead of disappearing like the blue one
Green coin got hit:
The green coin is this appearing but the red coin tile still switches
Red coin got hit: Cant post more than two Pictures :(. The red coin is disappering and everything is fine. But only if I hit them one after another. So i mean in the order: Redcoin, Greencoin, Bluecoin
I noticed something really weird:
As normal i hit it and it moved so its still bugged
but:
Thank you for your time!
 
     
    