Java – bitmap font reversal when using assetmanager

Today, I started using assetmanager in libgdx to load my assets Before that, I had loaded everything into a separate class, but I didn't use assetmanager

manager.load("font/good_neighbors_unity.fnt",BitmapFont.class);
[...]
bFont = manager.get("font/good_neighbors_unity.fnt",BitmapFont.class);

My problem is that when I load using asset manager, the bitmap font I use is reversed This is because in my orthographic camera, y points down There is a Boolean value in the bitmap font constructor to flip the font and avoid this problem But when I load it with assetmanager, there seems to be no such option There may be a relatively simple solution, but I can't find any way to allow me to flip fonts Is there an option that allows me to flip bitmap fonts when using assetmanager?

Solution

You can use the parameter object to specify flipping to the asset manager

BitmapFontLoader.BitmapFontParameter bitmapFontParameter = new BitmapFontParameter();
bitmapFontParameter.flip = true;
manager.load("font/good_neighbors_unity.fnt",BitmapFont.class,bitmapFontParameter);

Double parentheses in anonymous classes may allow you to do this in a single line:

manager.load("font/good_neighbors_unity.fnt",new BitmapFontLoader.BitmapFontParameter(){{flip = true;}});
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>