2016-10-13 9 views
0

타일을 삭제하기 위해 사용하는 코드입니다. 삭제할 수 있습니다.코인 타일을 없애는 방법 LibGDX

public TiledMapTileLayer.Cell getCell(){ 
    TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get(1); 
    return layer.getCell((int)(body.getPosition().x * Constants.PPM/32), 
      (int)(body.getPosition().y * Constants.PPM/32)); 
} 

문제는 큰 2x2 크기의 Bo2dWorld에 동전이 있다는 것입니다.

이 방법을 사용하면 코인 타일의 오른쪽 상단 모서리 셀만 삭제됩니다 ...하지만 동전 4 개를 모두 삭제하고 싶습니다. 그 방법을 아는 사람이 있습니까?

답변

0

동전은 2 × 2 타일이 크고, 당신은 단지

하나의 옵션이 광고에 타일의 동전 타일에 대한 속성입니다() 당신의 getCell에서 그 타일에 돌아갑니다. 그것을 "CoinTileCorner"와 같은 것으로 부르십시오. 그런 다음 "TopLeft", "TopRight", "BottomLeft"및 "BottomRight"4 타일을 호출하십시오.

이제 getCell에서 반환 된 셀을 얻으면 속성을 확인하고 제거 할 다른 타일을 알 수 있습니다.

private void removeCoin(cell){ 
    String corner = cell.getTile().getProperties().get("CoinTileCorner"); 

    if(corner.equals("TopLeft")){ 
     //remove this cell, the cell to the right, below and the one bellow on the right. 
    else if(corner.equals("TopRight")){ 
     //remove this cell, the one to the left... and so on and so forth. 
    } 
} 
+0

대단히 감사합니다! – MarioVZ