gpt4 book ai didi

java - 如何在libgdx中创建没有标题栏的窗口

转载 作者:行者123 更新时间:2023-11-30 02:26:52 25 4
gpt4 key购买 nike

我有一个项目需要如下所示:

enter image description here

使用窗口我得到以下结果

enter image description here

我使用以下代码创建上述结果

private Table buildControlsWindowLayer() {
Window window = new Window("", skinLibgdx);
// + play button
playButton = new Button(maputoSkin, "play");
window.add(playButton).pad(10, 0, 10, 0).row();
playButton.addListener(listener);
// + options button
optionsButton = new Button(maputoSkin, "options");
window.add(optionsButton).pad(10, 0, 10, 0).row();
optionsButton.addListener(listener);
// + leaders button
leadersButton = new Button(maputoSkin, "leaders");
window.add(leadersButton).pad(10, 0, 10, 0).row();
leadersButton.addListener(listener);
if (Constants.DEBUG_FLAG_MENU_SCREEN) window.debug();
window.pack();
window.setPosition(Constants.VIEWPORT_GUI_WIDTH / 2 - window.getWidth()/2,
Constants.VIEWPORT_GUI_HEIGHT/2 - window.getHeight());
return window;
}

我的问题

我。如何去掉标题栏

二.如何设置自己的背景而不是 libgdx 默认背景

三.对于第三种情况,这种方法是否正确?

最佳答案

com.badlogic.gdx.scenes.scene2d.ui.Window 带有一个构造函数: Window(java.lang.String title, Window.WindowStyle style)还有一个 setStyle(Window.WindowStyle style) 方法。 Window.WindowStyle 类允许您定义此窗口的样式,包括背景。 (https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Window.WindowStyle.html)

根据 libgdxs 文档,标题栏是一个窗口:

“一个可以拖动并充当模态窗口的表格。顶部填充用作窗口的标题高度。”,我没有找到任何直接的方法来摆脱标题栏,但是如果你扩展窗口类,您可以覆盖其中的一些功能以获得所需的结果。查看其来源:https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Window.java

要回答第三个问题,您必须提供更多信息,在这种情况下您的意思是什么?

关于java - 如何在libgdx中创建没有标题栏的窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45426566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com