LibGDX - How to smooth out actor drawable when scaling a Scene2d stage?

最后都变了- 提交于 2019-12-05 22:57:34

问题


This is my set-up:

stage = new Stage(1280, 800, false);
button = new Button(drawableUp, drawableDown);
stage.add(button);

this gets rendered as following:

@Override
public void render(float delta) {

    Gdx.gl.glClearColor(RED,GREEN,BLUE,ALPHA);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    stage.act(delta);

    stage.draw();
}

The issue is that when the stage is shown on 1280x800 the button looks like that:

If the stage is rescaled to e.g. 1280x736, the button drawable is scaled in the following way:

Is there a way to smooth out the edges somehow? Because right now it looks to me that the scaling is simply done by removing one pixel line in the upper half and one in the lower half of the picture.


回答1:


Are you using filters anywhere in your code? If not, then try this:

texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

Where texture is the texture object that you're using.



来源:https://stackoverflow.com/questions/15807063/libgdx-how-to-smooth-out-actor-drawable-when-scaling-a-scene2d-stage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!