Libgdx:阶段正在搞乱批处理

Jol*_*lly 2 java eclipse sprite libgdx spritebatch

我的代码有问题,在我开始使用步骤绘制我的UI之后出现,我有三个用Batch绘制的东西,一个舞台有2个按钮由Stage绘制,但只有2个我的"Sprites"正在画.这是代码:

public void render(float delta) {
    Gdx.gl.glClearColor(0.95F, 0.95F, 0.95F, 0.95F);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    deltaTime = Gdx.graphics.getDeltaTime();

    camera.update();
    generalUpdate(touch, camera, deltaTime, pointer);
    bounce(deltaTime);

    stage.setCamera(camera);
    batch.setProjectionMatrix(camera.combined);

    batch.begin();
        batch.draw(Assets.spr_bg, 0, 0);
        batch.draw(Assets.spr_title, 540-Assets.spr_title.getWidth()/2, titleY-Assets.spr_title.getHeight()/2);
        Assets.font_small.draw(batch, "some text", 540-Assets.font_small.getBounds("(c)2014 HateStone Games").width/2, 1920-64-Assets.font_small.getBounds("(c) HateStone Games").height/2);
        stage.draw();
    batch.end();
}
Run Code Online (Sandbox Code Playgroud)

它是文本"Some text",它不会被绘制出来,如果我将它注释掉,它会变得疯狂,标题精灵也不会被绘制,并且灰色框会以随机的间隔出现.

如果我移动"stage.draw();" 在批次之外它不会被绘制

Spr*_*bua 6

Stage有自己的SpriteBatch,吸取一切.所以你begin()有一段SpriteBatch时间你的另一个SpriteBatch正在画画.所以调用batch.end()之前调用stage.draw().这应该可以解决您的问题.