我的所有屏幕都按预期工作,只有当一个屏幕调用另一个屏幕时闪烁。一个例子是从我的主屏幕调用StoreScreen,但这会在所有屏幕上发生。
这是我的主屏幕显示,渲染和调用另一个屏幕的按钮。
public StoreScreen(TiltorGame tiltorGame) {
game = tiltorGame;
w = 800;
h = 480;
shapeDebugger = new ShapeRenderer();
}
@Override
public void show() {
camera = new OrthographicCamera();
camera.setToOrtho(false, w, h);
FitViewport viewp = new FitViewport(w, h, camera); // change this to
// your needed
// viewport
stage = new Stage(viewp); // also pass the singelton batch here. Try
// just to use onee batch to have a good
// performance.
Gdx.input.setInputProcessor(stage);
font = new BitmapFont();
font.setColor(0.5f, 0.4f, 0, 1); // Brown is an underated Colour
shapeDebugger = new ShapeRenderer();
table1 = new Table();
table2 = new Table();
table3 = new Table();
drawTable1();
}
//
@Override
public void render(float delta) {
// Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
drawLines();
stage.getBatch().begin();
Assets.backgroundSprite.draw(stage.getBatch());
table1.setBounds(0, 0, w / 3, h);
table2.setBounds(table1.getWidth(), 0, w / 3, h);
table3.setBounds(table1.getWidth() * 2, 0, w / 3, h);
stage.addActor(table1);
stage.addActor(table2);
stage.addActor(table3);
font.draw(stage.getBatch(), "Coins: " + String.valueOf(Data.coins),
400, 35);
font.draw(stage.getBatch(),
"FPS: " + String.valueOf(Gdx.graphics.getFramesPerSecond()),
700, 450);
stage.getBatch().end();
stage.act(Gdx.graphics.getDeltaTime());
stage.getBatch().setProjectionMatrix(camera.combined);
stage.draw();
}
//
TextButton buttonStore = new TextButton("Store", skin, "default");
buttonStore.setWidth(400f);
buttonStore.setHeight(75f);
buttonStore.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new StoreScreen(game));
}
});
table1.add(buttonStore);
table1.row();
此处还有StoreScreen节目
@Override
public void show() {
camera = new OrthographicCamera();
camera.setToOrtho(false, w, h);
FitViewport viewp = new FitViewport(w, h, camera); // change this to
// your needed
// viewport
stage = new Stage(viewp); // also pass the singelton batch here. Try
// just to use onee batch to have a good
// performance.
Gdx.input.setInputProcessor(stage);
font = new BitmapFont();
font.setColor(0.5f, 0.4f, 0, 1); // Brown is an underated Colour
table1 = new Table();
drawButtons();
}