我的代码有问题,在我开始使用步骤绘制 UI 后出现,我用 Batch 绘制了 3 个东西,Stage 绘制了一个带有 2 个按钮的舞台,但我的“精灵”中只有 2 个正在画。这是代码:
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();” 在批次之外它不会被绘制