2
我的代码有问题,在我开始使用步骤绘制UI之后出现,我有3件事情正在使用Batch进行绘制,并且舞台上有2个按钮由Stage绘制,但我的“精灵”中只有2个正在绘制。下面是代码:Libgdx:舞台正在搞批处理
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();
}
它是文本“一些文本”不拿得出,如果我注释掉,它会疯狂的,标题精灵不拿得出任何和灰色框随机出现。
另外,如果我移动“stage.draw();”在批次之外它没有被绘制
你应该在'batch.begin() - batch.end()'块之外将'stage.draw()'明确地移动。两个绘图'SpriteBatch''不能很好地结合在一起......你也不需要调用'Gdx.Graphics.getDelta()',因为你的render方法中有一个参数delta。只是我会解决一些问题。 – Springrbua
它的工作将'stage.draw()'移动到批处理后:) – Jolly
我已经阅读了您的问题中的最后一句话后删除了我的答案xD – Springrbua