2016-10-13 2 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)); 
} 

問題は私のBo2dWorldにコインが2x2の大きさであることです。

このメソッドをコールすると、コインタイルの右上のコーナーセルだけが削除されます...しかし、私はコインの4つのセルをすべて削除します。 誰でもその方法を知っていますか?

答えて

0

コインは大きな2x2のタイルで、あなただけ(あなたのgetcellを中にこれらのタイルの上で返す)

1つのオプションは、広告にタイル張りでコインタイルにプロパティです。それを "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

関連する問題