2013-04-04 87 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