簡體   English   中英

libGDX 中的對話框顯示不正確

[英]Dialog is displayed incorrectly in libGDX

我正在嘗試制作一個對話框並執行以下代碼,但它沒有在屏幕上正確顯示。

 batch = new SpriteBatch(); camera = new OrthographicCamera(); camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Viewport view = new StretchViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); view.setCamera(camera); stage=new Stage(view,batch); Skin skin=new Skin(); FileHandle fileHandle = Gdx.files.internal("uiskin.json"); FileHandle atlasFile = fileHandle.sibling("uiskin.atlas"); skin.addRegions(new TextureAtlas(atlasFile)); skin.load(Gdx.files.internal("uiskin.json")); card=new Card("Hello",skin ); Gdx.input.setInputProcessor(stage); card.show(stage);

在此處輸入圖像描述

可能是什么問題呢?

根據您的回復,您希望對話框是水平的而不是垂直的。

LibGDX 項目默認在橫向模式下運行,當您旋轉手機或平板電腦時不會旋轉。 如果您沒有更改此設置,那么這可能就是您的對話框橫向顯示的原因。 我在我的項目中使用fullUser進行設備輪換。

編輯 android 項目中的AndroidManifest.xml文件,並像這樣設置screenOrientation

android:screenOrientation="fullUser"

您可以在此處查看所有可用選項:

https://developer.android.com/guide/topics/manifest/activity-element.html#screen

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM