繁体   English   中英

libgdx阶段问题

[英]Libgdx stage issue

我正在尝试创建一个阶段,在该阶段上绘制Textbuttons。

我可以正常启动程序,没有任何错误。 但是没有出现文本按钮。

问题可能是我无法设置我正在使用的舞台大小。

这是初始化代码:

@Override public void resize(int width,int height){if(stage == null)stage = new Stage();

        stage.clear();

        Gdx.input.setInputProcessor(stage);

        TextButtonStyle style = new TextButtonStyle();

        style.up = skin.getDrawable("Button");

        style.down = skin.getDrawable("Button");

        style.font = buttonFont;

        startGameBtn = new TextButton("Start Game", style);

        startGameBtn.setWidth(300);

        startGameBtn.setHeight(150);

        startGameBtn.setX(Gdx.graphics.getWidth() / 2 - startGameBtn.getWidth() / 2);

        startGameBtn.setY((float) (Gdx.graphics.getHeight() / 1.5));

        startGameBtn.addListener(new InputListener() 
        {

        });

        stage.addActor(startGameBtn);

    }

这是我绘制按钮的位置:

public void render(float delta) 
{
    Gdx.gl20.glClearColor(0, 0, 0, 1);

    Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);

    stage.act(delta);

    sb.begin();


    stage.draw();


    sb.end();
}

感谢您的任何帮助! :)

解决了问题!

我不小心有一个黑色背景和一个黑色按钮,所以它实际上是在绘制它,我只是看不到它。

干杯!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM