LibGDX - 缩放 Scene2d 舞台时如何平滑可绘制的演员? [英] LibGDX - How to smooth out actor drawable when scaling a Scene2d stage?

查看:27
本文介绍了LibGDX - 缩放 Scene2d 舞台时如何平滑可绘制的演员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的设置:

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

这会呈现如下:

@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();
}

问题是当舞台以 1280x800 显示时,按钮看起来像这样:

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

如果舞台被重新调整为例如1280x736,可绘制的按钮按以下方式缩放:

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.

推荐答案

您是否在代码中的任何位置使用过滤器?如果没有,那么试试这个:

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

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

其中 texture 是您正在使用的纹理对象.

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

这篇关于LibGDX - 缩放 Scene2d 舞台时如何平滑可绘制的演员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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