您好以下代码来自我的主类,试图调用另一个实现屏幕的类。
if (grumpface.whiteballoon.getBoundingRectangle().overlaps(spriterect)) {
System.out.println("hey");
setScreen(new GameOverScreen());
}
;
这是我打电话的课程。
class GameOverScreen implements Screen{
private Stage stage;
// Called automatically once for init objects
@Override
public void show() {
stage = new Stage();
float delta = Gdx.graphics.getDeltaTime();
stage.setDebugAll(true); // Set outlines for Stage elements for easy debug
BitmapFont white = new BitmapFont(Gdx.files.internal("hazey.fnt"), false);
LabelStyle headingStyle = new LabelStyle(white, Color.WHITE);
Label gameoverstring = new Label("game ovaaaa!", headingStyle);
gameoverstring.setPosition(100, 100);
stage.addActor(gameoverstring);
}
// Called every frame so try to put no object creation in it
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
System.out.println("hey");
stage.act(delta);
stage.draw();
}
即使我没有返回任何堆栈错误,我的程序仍然不会在执行事件时切换屏幕。我可以告诉gameoverscreen类被调用,因为每当事件发生时,System.out.println("hey");
被触发并在控制台中启动。但是,没有颜色清晰或标签图纸应该有。