【发布时间】: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();
}
【问题讨论】: