我已經花了幾個小時試圖解決這個問題,並且我瘋了,請看看我的問題。當setFillParent爲true時,演員的位置是錯誤的,在LibGDX
圖片示出了此問題:
當
exitButton
的setFillParent
功能被設定爲false
的 結果是圖像的右邊,按鈕居中 內的Container但大小是錯誤的。當
exitButton
的setFillParent
功能被設置爲所述true
結果 是圖像的左側,按鈕的尺寸正確地 但位置是錯誤的。
下面的代碼:
Container container = new Container(exitButton);
container.fill();
container.setRound(false);
container.setSize(buttonSize, buttonSize);
exitButton.setFillParent(true);
//exitButton.setFillParent(false);
container.setPosition(
((float)viewportWidth/7f) - (buttonSize/2f)
,((float)viewportHeight*5f/6f) - (buttonSize/2f)
);
什麼有關[這](https://stackoverflow.com/questions/43958162/having-problems-with-the-layout-widget-container-in-libgdx)的問題,尋找類似 – Aryan
使用'scale'而不是'resize'也可以對容器進行轉換。 – Aryan