2013-04-04 37 views
7

这是我的设置:LibGDX - 在缩放Scene2d舞台时如何平滑actor drawable?

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

的问题是,当在1280×800显示在舞台按钮看起来像这样:

unscaled image

如果舞台重新缩放到eg 1280x736,按钮可绘制按以下方式缩放: scaled image

是否有办法平滑边缘?因为现在看起来缩放只是通过去除图片上半部分和下半部分中的一条像素线完成的。

回答

13

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

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

哪里texture是,你正在使用的纹理对象。

+1

谢谢。你指出了我的正确方向。我已经使用: tex = new Texture(); tex.setFilter(TextureFilter.MipMapLinearLinear,TextureFilter.Linear); – schafant 2013-04-04 14:33:09