【问题标题】:libgdx - bmfont custom font not drawing?libgdx - bmfont 自定义字体不绘图?
【发布时间】:2015-05-05 21:08:13
【问题描述】:

您好,下面的代码正在尝试将自定义字体绘制为标签。每当我在调试模式下绘制它时,我会在应该显示文本的位置周围出现一个绿色框,但什么也没有出现。我从来没有使用过自定义字体,只有那些已经安装在我电脑上的字体。但是,我的资产文件夹中确实有“.png”,所以我不明白为什么它不绘图。

堆栈跟踪中没有错误,下面的图片可以帮助描述问题。

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);
            white.setScale(2);
            LabelStyle headingStyle = new LabelStyle(white, Color.BLACK);
            Label gameoverstring = new Label("game over", 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((float)96/255,(float)96/255,(float)96/255, 1f);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        System.out.println("hey");


        stage.act(delta);

        stage.draw();



    }

http://imgur.com/C1NOUbK

【问题讨论】:

    标签: java android libgdx


    【解决方案1】:

    或多或少一字不差地使用了您的代码,它似乎可以工作:http://i.imgur.com/V54okhA.png

    你的字体可能被破坏了,试试:

    BitmapFont white = new BitmapFont();
    

    使用默认值并检查它是否有效。如果是这样,请确保您的字体包含所有必需的字形。也不要缩放字体,它们看起来很糟糕。

    【讨论】:

      【解决方案2】:

      听起来可能和this question有类似的问题

      您的项目运行情况如何?如果它来自桌面上的 IDE,您是否记得将当前工作目录设置为 android/assets?

      如果没有,那么它将找不到字体文件,这可能会导致您看到的问题。

      顺便说一句,很抱歉将其发布为答案 - 我没有足够的声誉将其发布为评论。

      【讨论】:

        猜你喜欢
        • 2022-07-25
        • 1970-01-01
        • 2016-07-30
        • 2015-07-20
        • 2014-04-23
        • 2014-11-30
        • 1970-01-01
        • 1970-01-01
        • 2014-07-01
        相关资源
        最近更新 更多