绘制在 libgdx 中旋转的 BitmapFont

Draw a BitmapFont rotated in libgdx(绘制在 libgdx 中旋转的 BitmapFont)

本文介绍了绘制在 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

基础教程推荐