gpt4 book ai didi

dialog - Libgdx - 如何让对话框淡出而不是整个舞台?

转载 作者:行者123 更新时间:2023-12-05 08:57:42 26 4
gpt4 key购买 nike

当我显示一个对话框时

someDialog.show(someStage);

对话框显示默认淡入 Action 。舞台也淡入淡出。所以它让我的背景随着舞台一起褪色。

我怎样才能防止这种情况发生?

编辑:这是我的示例代码:

在屏幕显示方法中:

Texture bg = new Texture(Gdx.files.internal(src));
stage = new Stage(game.getViewport(), batch);
stage.addActor(someDialog) //just normal dialog

渲染代码:

@Override
public void render(float delta) {
super.render(delta);
getBatch().begin();
getBatch().draw(backgroundTexture, 0, 0, width, height);
getBatch().end();
getStage().act(delta);
getStage().draw();
time += delta;
}

我在某些事件触发时显示对话框:

   dialog.show(getStage());

我尝试将 null 作为 show 方法的第二个参数

dialog.show(getStage(), null);

并使舞台和对话都不会淡入,但希望只保留对话或至少不保留背景的效果。

最佳答案

Stage 完成后不会清除 SpriteBatch 的颜色,因此当循环返回时,上次使用的颜色仍会应用于 Sprite 批处理。在您的情况下,最后使用的颜色恰好是对话框的颜色。

要解决此问题,请在 getBatch().draw(backgroundTexture, 0, 0, width, height); 之前添加 getBatch().setColor(Color.WHITE);;行。

而且我不认为你的整个舞台都在褪色。现在,您的背景纹理与舞台无关,只是它们共享 SpriteBatch。

关于dialog - Libgdx - 如何让对话框淡出而不是整个舞台?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30149994/

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