Dialog的目标位置Libgdx [英] Dialog's object position Libgdx

查看:280
本文介绍了Dialog的目标位置Libgdx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对话框:

Dialog dialog=new Dialog("",style);
dialog.setSize(400, 500);
dialog.setPosition(Gdx.graphics.getWidth()/2-200, Gdx.graphics.getHeight()/2-300);

我在里面添加两个按钮:

I added a two button in it:

 dialog.button(stopButton);
 dialog.button(goButton);

我的问题是我不能改变按钮的位置,而不是即使施加手动的按钮保持在相同的位置。

My problem is that I can not change the position of buttons, not even if the imposed manually the buttons remain in the same position.

我怎么可以做些什么来解决这个问题?

how could I do to solve the problem?

感谢您

推荐答案

一个libgdx对话框的按钮被添加到<一个href=\"http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Dialog.html#getButtonTable--\"相对=nofollow> ButtonTable 对话框,则可以通过调用获得此表 getButtonTable()方法,然后安排像你这样的按钮将与任何其他表做

The buttons of a libgdx dialog get added to the ButtonTable of the Dialog, you can get this table by calling getButtonTable() method and then arrange the buttons like you would do it with any other Table.

以下code将使goButton的STOPBUTTON下面的例子:

The following code would place goButton below the stopButton for example:

dialog.button(stopButton);
dialog.getButtonTable().row();
dialog.button(goButton);

如果要微调布局越多,你可以只添加按钮到表,并使用一些TableLayout方法,例如像下面的code会增加一些填充:

If you want to fine-tune the layout more, you could just add the buttons to the table and use some TableLayout methods, like for example the below code would add some padding:

dialog.getButtonTable().add(stopButton).pad(20);
dialog.getButtonTable().add(goButton).pad(20);

这篇关于Dialog的目标位置Libgdx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆