1
我想在我的游戏中绘制一些字体(在libgdx中)。我没有错误,一切正常,但我没有看到字体。我不知道为什么。也许有人有同样的问题。感谢帮助。 这里是我的代码 在创建方法:不会在libgdx中绘制字体
String scores = "SCORE:";
atlas = new TextureAtlas();
camera = new OrthographicCamera(1, h/w);
batch = new SpriteBatch();
score = new BitmapFont(Gdx.files.internal("gfx/abc.fnt"),
atlas.findRegion("gfx/abc.png"), false);
和渲染:
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
camera.update();
batch.setProjectionMatrix(camera.combined);
batch.begin();
score.draw(batch, scores, 300, 300);
Gdx.app.log("", ""+scores);
batch.end();
现在,您在渲染器内部生成了一个不错的新对象。创建Matrix4作为该类的一个分类,并设置正交。 – BennX
BennX是对的。你的问题的另一个解决方案是设置你的字体的大小与你的视口比例的比例。 类似font.setsize(size.x/40,size.y/40); 语法不正确,但我知道你会弄明白 –