如何在 libgdx 中更改位图字体的 alpha

2022-01-12 00:00:00 bitmap java libgdx

我想制作一个消息框,当您接受时会消失,但我不知道如何更改字体的 alpha,

I want to make a message box that fade when you accept but I don't know how to change the alpha of a font,

我的字体是这样的:

white = new BitmapFont(Gdx.files.internal("data/font/whitefont.fnt"),false);
white.setUseIntegerPositions(false);
white.setScale(0.025f);
white.draw(batchHUD, message.nom+":", 1000*0.1f+(1000*0.8f*0.3f), 625*0.1f+(1000*0.8f*0.625f*0.5f*0.1f)+1000*0.2f);

谁能帮帮我?:) 对不起,我的英语不是我的母语.

Can anyone help me ? :) I'm sorry for my english, it's not my native language.

推荐答案

white.setColor(1, 1, 1, <alpha>);

这将更改所有后续绘制的字体的 alpha.因此,您可能希望在绘制该消息后再次将其设置为完全不透明.

This will change the alpha of the font for all following draws. So you would probably want to set it to full opaque again once you draw that message.

white.setColor(1, 1, 1, 1);

相关文章