1
我正在編程LIBGX中的一個按鈕。它適用於臺式機好,但是當我啓動它在Android上,我有一個不同的地方接觸(使用真正的Android設備,而不是一個AVD林)來觸發它下面是描述它一峯:在Android設備上着落時獲得正確的座標
下面的TouchDown代碼:
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown (int x, int y, int pointer, int button) {
// your touch down code here
Vector3 coords = new Vector3(x, y, 0);
camara.unproject(coords);
if(coords.x >= 52 && coords.x<=129 && coords.y >= 158 && coords.y<=253){
shoot(1);
}
return true; // return true to indicate the event was handled
}
});
我有同樣的問題沒有的Vector3,我開始使用它,因爲它是勸,但沒有太多解決。下面是攝像頭的聲明:
camara = new OrthographicCamera();
camara.setToOrtho(false, 800, 480);
我做了一些調查,但無法找到合適的解決方案,我發現相機(ortographic,現實世界中,等)十分混亂。我會繼續挖掘,這需要數小時,並且必須提出問題。我希望有人能指出我正確的方向。
不知道我是否可以直接幫你,但我可以告訴你,x和y在Android座標相比,計算機有所反轉。 x和y座標從左上角開始,而不是在其他操作系統上的左下角開始。請參閱:http://stackoverflow.com/questions/11483345/how-android-screen-coordinates-works更多解釋(抱歉,找不到任何直接從文檔中找到的東西)。 – Darwind 2014-08-28 19:26:47
@Darwind謝謝非常,我會看看,謝謝你的評論 – dasjkdj 2014-08-28 19:27:26