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

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

问题描述

这是我的设置

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舞台时如何平滑actor可绘制对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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