[英]Center libgdx stage object
對於libgdx項目,我想讓頂部的3個圖像並排居中,但是由於某種原因,中間的一個圖像沒有居中,因此它們不會到達頂部。 它們連接到按鈕“后退” actor。
我試過了:
Table table = new Table();
table.setFillParent(true);
table.setBackground(new TextureRegionDrawable(new TextureRegion(new Texture("background.png"))));
table.padTop(50);
table.add(characters).top().left();
table.add(items).top();
table.add(upgrades).top().right();
table.row();
table.bottom();
table.add(back).size(back.getWidth(), back.getHeight()).colspan(2).padBottom(70);
table.row();
stage.addActor(table);
如果您能以某種方式說明自己要達到的目標以及取得的結果,將很容易回答您的問題。 (這樣做永遠不會太晚)
無論如何:您有3張圖片,並且希望它們在頂部彼此接觸。
table.top();
table.add(characters).expandX().padTop(50);
table.add(items).expandX().padTop(50);
table.add(upgrades).expandX().padTop(50);//three images fill up total space given
應該給你想要的布局。
打開table.setDebug(true);
通過在表,單元格和小部件周圍繪制調試線來幫助您進行調試。
如果您正在尋找有關該主題的更多信息,那么可以找到Table
的出色Wiki: https : //github.com/libgdx/libgdx/wiki/Table
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.