我正在製作一款採礦遊戲,如果你點擊某個地方,你會刪除鋪設的地塊。現在所有的塊都只是正方形,並且只有在我的2d布爾數組中的位置爲真時才被繪製。所以,我想採取這樣的立場,並將其設置爲false,無論你點擊這裏是我的inputprocessor
輸入不能抓取正確的座標libgdx java
private Vector2 tmp = new Vector2();
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
tmp.x = screenX/MapGrid.CELL_SIZE;
tmp.y = screenY/MapGrid.CELL_SIZE;
cam.unproject(new Vector3(tmp.x, tmp.y, 0));
grid.manipulateGrid((int)(tmp.x), (int)(tmp.y), false);
System.out.println("Clicked at: (" + tmp.x + ", " + tmp.y +")");
return false;
}
的着陸方法,我也有翻譯相機我的球員的位置。 grid.manipulateGrid
需要一個x和一個y並將其設置爲false。我的球員位於網格座標(10,126),當我點擊他旁邊時,它說我點擊(35,24)我不確定我是否正在做這件事,但我一直在尋找到處,並且可以找不到解決方案。我發現類似的問題,但沒有結果。如果有人能告訴我如何將點擊調整到玩家的座標,我會感到難以置信的欣賞。
謝謝!!!!這工作完美 – Luke