当屏幕暂停时,我在游戏逻辑中调用applyEffect,但图像未设置。取而代之的是我的黑色背景。相反,当我设置高斯模糊着色器时,我希望它显示模糊的纹理,在下面的图像中的形式。
遗憾的是结果是
为什么屏幕变黑?
以下是我如何调用方法
if (Gdx.input.isKeyPressed(Keys.P) || pause)
{
state = State.GAME_PAUSED;
setBackgroundTexture(applyEffect());
gameScreenGamePauseMenu.sendInMenu();
}
public TextureRegion applyEffect()
{
boolean m_fboEnabled = true;
FrameBuffer m_fbo = null;
float m_fboScaler = 1;
TextureRegion m_fboRegion = null;
int width = Gdx.graphics.getWidth();
int height = Gdx.graphics.getHeight();
if(m_fboEnabled) // enable or disable the supersampling
{
if(m_fbo == null)
{
// m_fboScaler increase or decrease the antialiasing quality
m_fbo = new FrameBuffer(Format.RGB565, (int)(width * m_fboScaler), (int)(height * m_fboScaler), false);
m_fboRegion = new TextureRegion(m_fbo.getColorBufferTexture());
m_fboRegion.flip(false, true);
}
m_fbo.begin();
}
if(m_fbo != null)
{
m_fbo.end();
getStage().getBatch().begin();
getStage().getBatch().draw(m_fboRegion, 0, 0, width, height);
getStage().getBatch().end();
}
return m_fboRegion;
}
我使用Libgdx制作我的游戏