Draw a BitmapFont rotated in libgdx(绘制在 libgdx 中旋转的 BitmapFont)
问题描述
我似乎无法弄清楚如何正确旋转位图字体.我认为您修改了 SpriteBatch 的转换矩阵.但是,尝试旋转会使文本围绕某个点旋转,我不知道如何相对于文本本身旋转它.
I can't seem to figure out how to rotate a Bitmap font correctly. I think you modify the transformation matrix of the SpriteBatch. However, trying to rotate that rotates the text around some point, and I don't know how to rotate it relative to the text itself.
推荐答案
你可以试试下面的代码:
you can try the following code:
Matrix4 mx4Font = new Matrix4();
BitmapFont font;
SpriteBatch spriteFont;
font = new BitmapFont(Gdx.files.internal("data/font/agencyFB.fnt"), Gdx.files.internal("data/font/agencyFB.png"), true); //must be set true to be flipped
mx4Font.setToRotation(new Vector3(200, 200, 0), 180);
spriteFont.setTransformMatrix(mx4Font);
spriteFont.begin();
font.setColor(1.0f, 1.0f, 1.0f, 1.0f);
font.draw(spriteFont, "The quick brown fox jumped over the lazy dog", 100, 110);
spriteFont.end();
这篇关于绘制在 libgdx 中旋转的 BitmapFont的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:绘制在 libgdx 中旋转的 BitmapFont


基础教程推荐
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 从 python 访问 JVM 2022-01-01
- Java Swing计时器未清除 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01