ビットマップフォントを正しく回転させる方法がわからないようです。SpriteBatchの変換行列を変更すると思います。ただし、ある点を中心にテキストを回転させる回転を試みると、テキスト自体に対してテキストを回転させる方法がわかりません。
8068 次
4 に答える
5
グリフをスプライトに作成できます。そうすれば、テキストをスプライトとして操作できます。
コード例:
これは単一のグリフのスプライトを返すことに注意してください。(例: 文字 'A' はスプライトに変換されます。)
/** Creates a sprite from a glyph.
*
* @param ch
* @return Sprite
*/
public Sprite getGlyphSprite (char ch) {
Glyph glyph = Globals.g.font.getData().getGlyph(ch);
Sprite s = new Sprite(Globals.g.font.getRegion().getTexture(),
glyph.srcX,glyph.srcY,glyph.width, glyph.height);
s.flip(false, true);
s.setOrigin(glyph.width/2, glyph.height/2);
return s;
}
于 2013-03-28T19:43:20.227 に答える
4
次のコードを試すことができます。
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();
于 2012-03-10T18:42:18.650 に答える
0
追加するだけです..いくつかのアトラス内にフォントベースイメージがあると思います..そのため、TextureRegion originals sot gliph src を追加する必要があります。
BitmapFont font = ...
BitmapFont.Glyph glyph = font.getData().getGlyph(ch);
int srcX = glyph.srcX + font.getRegion().getRegionX();
int srcY = glyph.srcY+ font.getRegion().getRegionY();
Sprite s = new Sprite(font.getRegion().getTexture(), srcX,srcY,glyph.width, glyph.height);
于 2016-03-03T08:40:35.290 に答える