我試圖做libgdx遊戲,並且我現在有兩個問題: 1.當我使用camera.setToOrtho(false,GAME_WIDTH,GAME_HEIGHT);我的球員的textrure是偏遠的,一隻眼睛比另一隻眼睛大。使用這個攝像頭和viweport 2.進口:libgdx使用camera.setToOrtho(false,GAME_WIDTH,GAME_HEIGHT)時會產生扭曲的紋理;
camera= new OrthographicCamera(GAME_WIDTH,GAME_HEIGHT);
camera.setToOrtho(false, GAME_WIDTH, GAME_HEIGHT);
viewport = new StretchViewport(GAME_WIDTH,GAME_HEIGHT,camera);
,當我做:
touchPos.set(Gdx.input.getX(1),Gdx.input.getY(1),0);
game.camera.unproject(touchPos);
System.out.println(touchPos.x+" "+ touchPos.y);
我在右上角獲得0 0,但我的性格巫線0 0在左下角是借鑑。
當我使用:
game.camera = new OrthographicCamera(820,480);
game.viewport = new FillViewport(820,480,game.camera);
我必須使用game.batch.setProjectionMatrix(game.camera.combined);
當我使用這段代碼時,我得到了正確的工作方法和座標系,但是我已經感受到了變形的紋理。
當我使用:
camera = new PerspectiveCamera();
viewport = new StretchViewport(900, 470, camera);
我有distored質地和壞COORDS系統。我不能使用:game.batch.setProjectionMatrix(game.camera.combined);
對於第二個問題檢查接受的答案是這樣的:http://stackoverflow.com/questions/8104364/apply-pixel-coordinates-to-screen-coordinates –
thx unproject開始工作。 – peterSweter
現在一切正常嗎?然後我將創建評論作爲答案,以便人們以後清楚地看到解決方案。 –