找到你要的答案

Q:Graphic problems with libgdx stage2d.ui

Q:随着stage2d.ui libGDX图形问题

I'm playing with stage2d.ui... Just creating an empty stage with only a button, and it happens this in android (screenshot directly from a Nexus5): Screenshot from a Nexus5

Also, it looks ok in desktop, but if you resize the screen, you can see the image of the button flickering at its previous position like this (image after making the window a bit more width): Desktop behaviour

I'm not sure if I'm doing something wrong or it's just a graphic issue...

For the button widget, I'm using the test data like this:

stage = new Stage(new ScreenViewport());
Skin skin = new Skin(Gdx.files.internal("uiskin.json"));

TextButton button = new TextButton("Button 1", skin);
button.setSize(100, 50);
button.setPosition(10, 10);

stage.addActor(button);

And then in the main render method, stage.act(delta) and stage.draw() are called, of course.

For the resize part... here's the code

public void resize(int width, int height) {
    stage.getViewport().update(width, height);
}

I have other stages without ui widgets working fine, but this is my first time with ui and I'm not sure about what's happening here...

I'm playing with stage2d.ui... Just creating an empty stage with only a button, and it happens this in android (screenshot directly from a Nexus5): Screenshot from a Nexus5

Also, it looks ok in desktop, but if you resize the screen, you can see the image of the button flickering at its previous position like this (image after making the window a bit more width): Desktop behaviour

我不知道我做错了什么,或者只是一个图形问题…

对于按钮部件,我使用这样的测试数据:

stage = new Stage(new ScreenViewport());
Skin skin = new Skin(Gdx.files.internal("uiskin.json"));

TextButton button = new TextButton("Button 1", skin);
button.setSize(100, 50);
button.setPosition(10, 10);

stage.addActor(button);

然后在主渲染方法,阶段。法(三角洲)和舞台。draw()称,当然。

对于大小调整部分…这是代码

public void resize(int width, int height) {
    stage.getViewport().update(width, height);
}

我有其他阶段没有UI部件工作良好,但这是我第一次与用户界面,我不知道发生了什么…

answer1: 回答1:

Moved from comment above.

My guess is you are not clearing the screen at the start of your render method. Try adding Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if it isn't there already.

从以上评论移动。

我猜你不是在你的渲染方法开始时清理屏幕。尝试添加GDX。GL。glClear里(GL20。gl_color_buffer_bit);如果它不在那里了。

android  libgdx