Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/211.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Libgdx:设置屏幕问题_Java_Android_Libgdx - Fatal编程技术网

Java Libgdx:设置屏幕问题

Java Libgdx:设置屏幕问题,java,android,libgdx,Java,Android,Libgdx,您好,下面的代码来自我的主类,它试图调用我创建的另一个实现screen的类 if (grumpface.whiteballoon.getBoundingRectangle().overlaps(spriterect)) { System.out.println("hey"); setScreen(new GameOverScreen()); } ; 这是我要叫的班级 class GameOverScreen implem

您好,下面的代码来自我的主类,它试图调用我创建的另一个实现screen的类

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(“嘿”)。但是,没有像应有的那样的颜色清晰或标签图纸

不要那样使用Show()。您应该在构造函数中初始化对象。也许可以尝试这样设置屏幕:

((com.badlogic.gdx.Game) Gdx.app.getApplicationListener())
            .setScreen(new GameScreen());
我们需要查看更多代码来帮助您


ps我不能评论,但是链接:已经过时了,请检查:

看看BadLogicGames提供的示例语法:由于我不知道代码的上下文,您需要自己查找语法错误。